{"name":"@opentelemetry/instrumentation-undici","version":"0.10.0","description":"OpenTelemetry instrumentation for `undici` http client and Node.js fetch()","main":"build/src/index.js","types":"build/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git"},"scripts":{"prepublishOnly":"npm run compile","compile":"tsc -p .","test":"nyc mocha test/**/*.test.ts","test-all-versions":"tav","tdd":"npm run test -- --watch-extensions ts --watch","clean":"rimraf build/*","lint":"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix","watch":"tsc -w","prewatch":"npm run precompile","version:update":"node ../../../scripts/version-update.js"},"keywords":["opentelemetry","fetch","undici","nodejs","tracing","instrumentation"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","engines":{"node":">=14"},"publishConfig":{"access":"public"},"devDependencies":{"@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","@types/mocha":"7.0.2","@types/node":"18.18.14","nyc":"15.1.0","rimraf":"5.0.10","semver":"^7.6.0","test-all-versions":"6.1.0","typescript":"4.4.4","undici":"6.11.1"},"peerDependencies":{"@opentelemetry/api":"^1.7.0"},"dependencies":{"@opentelemetry/core":"^1.8.0","@opentelemetry/instrumentation":"^0.57.0"},"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-undici","sideEffects":false,"gitHead":"3ef5205e5353010184c69ff7b9f0f4830f0932de","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"_id":"@opentelemetry/instrumentation-undici@0.10.0","_nodeVersion":"18.20.5","_npmVersion":"lerna/6.6.2/node@v18.20.5+x64 (linux)","dist":{"integrity":"sha512-vm+V255NGw9gaSsPD6CP0oGo8L55BffBc8KnxqsMuc6XiAD1L8SFNzsW0RHhxJFqy9CJaJh+YiJ5EHXuZ5rZBw==","shasum":"99cba213a6e9d47a82896b6c782c3f2d60e0edb5","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-undici/download/@opentelemetry/instrumentation-undici-0.10.0.tgz","fileCount":21,"unpackedSize":109099,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-undici@0.10.0","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD30A81Nyi5I+buI6pl+fvSxOyKxgp03hOVP4V3bpiOgQIgcO8HxjiZ7ICdX8/GTHtQYJwBP8AVN4QMFCJ2GvDlU3U="}],"size":29519,"noattachment":false,"key":"/@opentelemetry/instrumentation-undici/-/@opentelemetry/instrumentation-undici-0.10.0.tgz"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/instrumentation-undici_0.10.0_1734524685269_0.06045170260502064"},"_hasShrinkwrap":false,"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\nprovider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));\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":1734524685449,"maintainers":[{"name":"bogdandrutu","email":"bogdandrutu@gmail.com"},{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"}],"_cnpm_publish_time":1734524685449,"dist-tags":{"latest":"0.32.0"}}