{"name":"@opentelemetry/instrumentation-undici","version":"0.10.1","keywords":["opentelemetry","fetch","undici","nodejs","tracing","instrumentation"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-undici@0.10.1","homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-undici","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"228b7fc267e55533708be16c43e70bbb51a691de","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-undici/download/@opentelemetry/instrumentation-undici-0.10.1.tgz","fileCount":21,"integrity":"sha512-rkOGikPEyRpMCmNu9AQuV5dtRlDmJp2dK5sw8roVshAGoB6hH/3QjDtRhdwd75SsJwgynWUNRUYe0wAkTo16tQ==","signatures":[{"sig":"MEUCICyBqvHa7dkm9QP8cWRTaEup6bu4et17hb+0I2PWtZVtAiEAgOdlfjLAYiCm+aGFgW9gkmsAfASN6Sow6IMEpbSPBHI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-undici@0.10.1","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"unpackedSize":109104,"size":29522,"noattachment":false,"key":"/@opentelemetry/instrumentation-undici/-/@opentelemetry/instrumentation-undici-0.10.1.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":">=14"},"gitHead":"1eb77007669bae87fe5664d68ba6533b95275d52","scripts":{"tdd":"npm run test -- --watch-extensions ts --watch","lint":"eslint . --ext .ts","test":"nyc mocha test/**/*.test.ts","clean":"rimraf build/*","watch":"tsc -w","compile":"tsc -p .","lint:fix":"eslint . --ext .ts --fix","prewatch":"npm run precompile","prepublishOnly":"npm run compile","version:update":"node ../../../scripts/version-update.js","test-all-versions":"tav"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git"},"_npmVersion":"lerna/6.6.2/node@v18.20.6+x64 (linux)","description":"OpenTelemetry instrumentation for `undici` http client and Node.js fetch()","directories":{},"sideEffects":false,"_nodeVersion":"18.20.6","dependencies":{"@opentelemetry/core":"^1.8.0","@opentelemetry/instrumentation":"^0.57.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"15.1.0","rimraf":"5.0.10","semver":"^7.6.0","undici":"6.21.1","typescript":"4.4.4","@types/node":"18.18.14","@types/mocha":"7.0.2","test-all-versions":"6.1.0","@opentelemetry/api":"^1.7.0","@opentelemetry/sdk-metrics":"^1.8.0","@opentelemetry/sdk-trace-base":"^1.8.0","@opentelemetry/sdk-trace-node":"^1.8.0"},"peerDependencies":{"@opentelemetry/api":"^1.7.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-undici_0.10.1_1739984900357_0.08479204769750548","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 load a specific instrumentation (Undici in this case), specify it in the Node Tracer's configuration.\n\n```js\nconst {\n  UndiciInstrumentation,\n} = require('@opentelemetry/instrumentation-undici');\nconst {\n  ConsoleSpanExporter,\n  NodeTracerProvider,\n  SimpleSpanProcessor,\n} = require('@opentelemetry/sdk-trace-node');\nconst { registerInstrumentations } = require('@opentelemetry/instrumentation');\n\nconst provider = new NodeTracerProvider({\n  spanProcessors: [\n    new SimpleSpanProcessor(new ConsoleSpanExporter()),\n  ],\n});\n\nprovider.register();\n\nregisterInstrumentations({\n  instrumentations: [new UndiciInstrumentation()],\n});\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/plugins/node/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/plugins/node/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/plugins/node/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/plugins/node/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/plugins/node/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/plugins/node/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":1739984900552,"maintainers":[{"name":"bogdandrutu","email":"bogdandrutu@gmail.com"},{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"}],"_cnpm_publish_time":1739984900552,"dist-tags":{"latest":"0.32.0"}}