{"name":"@opentelemetry/instrumentation-undici","version":"0.19.0","keywords":["opentelemetry","fetch","undici","nodejs","tracing","instrumentation"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-undici@0.19.0","maintainers":[{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"}],"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-undici#readme","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"a9db59a7630261269239d17d2990d406e2ecddf8","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-undici/download/@opentelemetry/instrumentation-undici-0.19.0.tgz","fileCount":18,"integrity":"sha512-Pst/RhR61A2OoZQZkn6OLpdVpXp6qn3Y92wXa6umfJe9rV640r4bc6SWvw4pPN6DiQqPu2c8gnSSZPDtC6JlpQ==","signatures":[{"sig":"MEUCIQD7TxgGJ4O/bKQbTpNl8J6+1fdhzqutHP5BaYWRPzKk7gIgKQmG42GcOoHa9UXSSKo3FhVXe3yNZ54misSrYXu1fsU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-undici@0.19.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":86099,"size":22954,"noattachment":false,"key":"/@opentelemetry/instrumentation-undici/-/@opentelemetry/instrumentation-undici-0.19.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":"^18.19.0 || >=20.6.0"},"gitHead":"94e5b7da4500459e38e8d4dfda93542f22159600","scripts":{"tdd":"npm run test -- --watch-extensions ts --watch","test":"nyc --no-clean mocha test/**/*.test.ts","clean":"rimraf build/*","watch":"tsc -w","compile":"tsc -p .","prepublishOnly":"npm run compile","version:update":"node ../../scripts/version-update.js","test-all-versions":"tav","compile:with-dependencies":"nx run-many -t compile -p @opentelemetry/instrumentation-undici"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:0ba02a5e-263f-4afc-a2ce-930683eebbb0"}},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git","directory":"packages/instrumentation-undici"},"_npmVersion":"lerna/9.0.0/node@v24.11.0+x64 (linux)","description":"OpenTelemetry instrumentation for `undici` http client and Node.js fetch()","directories":{},"sideEffects":false,"_nodeVersion":"24.11.0","dependencies":{"@opentelemetry/core":"^2.0.0","@opentelemetry/instrumentation":"^0.208.0","@opentelemetry/semantic-conventions":"^1.24.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"17.1.0","rimraf":"5.0.10","semver":"^7.6.0","undici":"6.21.3","typescript":"5.0.4","@types/node":"18.18.14","@types/mocha":"10.0.10","test-all-versions":"6.1.0","@opentelemetry/api":"^1.7.0","@opentelemetry/sdk-metrics":"^2.0.0","@opentelemetry/sdk-trace-base":"^2.0.0","@opentelemetry/sdk-trace-node":"^2.0.0"},"peerDependencies":{"@opentelemetry/api":"^1.7.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-undici_0.19.0_1762452065954_0.35586444676230755","host":"s3://npm-registry-packages-npm-production"},"readme":"# OpenTelemetry Undici/fetch Instrumentation for Node.js\n\n[![NPM Published Version][npm-img]][npm-url]\n[![Apache License][license-image]][license-image]\n\n**Note: This is an experimental package under active development. New releases may include breaking changes.**\n\nThis module provides automatic instrumentation for [`undici`](https://undici.nodejs.org/) and Node.js global [`fetch`](https://nodejs.org/docs/latest/api/globals.html#fetch) API.\nIf you're looking the instrumentation for browser's `fetch` API it is located at [https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch/](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch/)\n\n## Installation\n\n```bash\nnpm install --save @opentelemetry/instrumentation-undici\n```\n\n## Supported Versions\n\n- [`undici`](https://www.npmjs.com/package/undici) version `>=5.12.0`\n\n## Usage\n\nOpenTelemetry Undici/fetch Instrumentation allows the user to automatically collect trace data and export them to their backend of choice, to give observability to distributed systems.\n\nTo enable a specific instrumentation, pass it to `registerInstrumentations()`.\nThis is commonly done via `NodeSDK` for fully setting up all OpenTelemetry SDK components:\n\n```js\nconst { NodeSDK } = require('@opentelemetry/sdk-node');\nconst { UndiciInstrumentation } = require('@opentelemetry/instrumentation-undici');\n\nconst sdk = new NodeSDK({\n  instrumentations: [\n    new UndiciInstrumentation(),\n  ],\n});\nsdk.start();\nprocess.once('beforeExit', async () => { await sdk.shutdown(); });\n```\n\n### Undici/Fetch instrumentation Options\n\nUndici instrumentation has few options available to choose from. You can set the following:\n\n| Options                                                                                                                                            | Type                    | Description                                                                                                                                                                                                                                                  |\n|----------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`ignoreRequestHook`](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/packages/instrumentation-undici/src/types.ts#L73)       | `IgnoreRequestFunction` | Undici instrumentation will not trace all incoming requests that matched with custom function.                                                                                                                                                               |\n| [`requestHook`](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/packages/instrumentation-undici/src/types.ts#L75)             | `RequestHookFunction`   | Function for adding custom attributes before request is handled.                                                                                                                                                                                             |\n| [`responseHook`](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/packages/instrumentation-undici/src/types.ts#L77)            | `ResponseHookFunction`  | Function for adding custom attributes after the response headers are received.                                                                                                                                                                               |\n| [`startSpanHook`](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/packages/instrumentation-undici/src/types.ts#L79)           | `StartSpanHookFunction` | Function for adding custom attributes before a span is started.                                                                                                                                                                                              |\n| [`requireParentforSpans`](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/packages/instrumentation-undici/src/types.ts#L81)   | `Boolean`               | Require a parent span is present to create new span for outgoing requests.                                                                                                                                                                                   |\n| [`headersToSpanAttributes`](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/packages/instrumentation-undici/src/types.ts#L83) | `Object`                | List of case insensitive HTTP headers to convert to span attributes. Headers will be converted to span attributes in the form of `http.{request\\|response}.header.header-name` where the name is only lowercased, e.g. `http.response.header.content-length` |\n\n### Observations\n\nThis instrumentation subscribes to certain [diagnostics_channel](https://nodejs.org/api/diagnostics_channel.html) to intercept the client requests\nand generate traces and metrics. In particular tracing spans are started when [undici:request:create](https://undici.nodejs.org/#/docs/api/DiagnosticsChannel?id=undicirequestcreate)\nchannel receives a message and ended when [undici:request:trailers](https://undici.nodejs.org/#/docs/api/DiagnosticsChannel?id=undicirequesttrailers) channel receive a message.\nThis means the full response body has been received when the instrumentation ends the span.\n\n## Semantic Conventions\n\nThis package uses Semantic Conventions [Version 1.24.0](https://github.com/open-telemetry/semantic-conventions/tree/v1.24.0/docs/http). As for now the Semantic Conventions\nare bundled in this package but eventually will be imported from `@opentelemetry/semantic-conventions` package when it is updated to latest version.\nRef: [opentelemetry-js/issues/4235](https://github.com/open-telemetry/opentelemetry-js/issues/4235)\n\nAttributes collected:\n\n| Attribute                      | Short Description                                                                                          |\n|--------------------------------|------------------------------------------------------------------------------------------------------------|\n| `error.type`                   | Describes a class of error the operation ended with.                                                       |\n| `http.request.method`          | HTTP request method.                                                                                       |\n| `http.request.method_original` | Original HTTP method sent by the client in the request line.                                               |\n| `http.response.status_code`    | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).                                |\n| `network.peer.address`         | Peer address of the network connection - IP address or Unix domain socket name.                            |\n| `network.peer.port`            | Peer port number of the network connection.                                                                |\n| `server.address`               | Server domain name, IP address or Unix domain socket name.                                                 |\n| `server.port`                  | Server port number.                                                                                        |\n| `url.full`                     | Absolute URL describing a network resource according to [RFC3986](https://www.rfc-editor.org/rfc/rfc3986). |\n| `url.path`                     | The [URI path](https://www.rfc-editor.org/rfc/rfc3986#section-3.3) component.                              |\n| `url.query`                    | The [URI query](https://www.rfc-editor.org/rfc/rfc3986#section-3.4) component.                             |\n| `url.scheme`                   | HTTP request method.                                                                                       |\n| `user_agent.original`          | Value of the HTTP User-Agent header sent by the client.                                                    |\n\n## Useful links\n\n- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>\n- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>\n- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]\n\n## License\n\nApache 2.0 - See [LICENSE][license-url] for more information.\n\n[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions\n[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE\n[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat\n[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-undici\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-undici.svg\n","publish_time":1762452066139,"_cnpm_publish_time":1762452066139,"dist-tags":{"latest":"0.32.0"}}