{"name":"@opentelemetry/instrumentation-http","version":"0.57.1","keywords":["opentelemetry","http","nodejs","tracing","profiling","instrumentation"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-http@0.57.1","homepage":"https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-http","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js/issues"},"dist":{"shasum":"2d8b395df62191475e76fa0eb7bf60079ea886b9","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-http/download/@opentelemetry/instrumentation-http-0.57.1.tgz","fileCount":24,"integrity":"sha512-ThLmzAQDs7b/tdKI3BV2+yawuF09jF111OFsovqT1Qj3D8vjwKBwhi/rDE5xethwn4tSXtZcJ9hBsVAlWFQZ7g==","signatures":[{"sig":"MEYCIQDRGK2wn6JCnYcqNnTb1JS7H6ATGTUOWdEoCP9wLBtiOwIhAPxWD2Qx4rss/ksmOLde7XOS1Ag7R0MVH5TIwe1tWbPx","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-http@0.57.1","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"unpackedSize":233791,"size":51767,"noattachment":false,"key":"/@opentelemetry/instrumentation-http/-/@opentelemetry/instrumentation-http-0.57.1.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":">=14"},"gitHead":"cbc912d67bda462ca00449d7ce7b80052c20a4fc","scripts":{"tdd":"npm run test -- --watch-extensions ts --watch","lint":"eslint . --ext .ts","test":"npm run test:cjs && npm run test:esm","clean":"tsc --build --clean","watch":"tsc --build --watch","compile":"tsc --build","version":"node ../../../scripts/version-update.js","lint:fix":"eslint . --ext .ts --fix","prewatch":"node ../../../scripts/version-update.js","test:cjs":"nyc mocha test/**/*.test.ts","test:esm":"nyc node --experimental-loader=@opentelemetry/instrumentation/hook.mjs ../../../node_modules/mocha/bin/mocha 'test/**/*.test.mjs'","precompile":"cross-var lerna run version --scope $npm_package_name --include-dependencies","align-api-deps":"node ../../../scripts/align-api-deps.js","peer-api-check":"node ../../../scripts/peer-api-check.js","prepublishOnly":"npm run compile","maint:regenerate-test-certs":"cd test/fixtures && ./regenerate.sh"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js.git","type":"git"},"_npmVersion":"lerna/6.6.2/node@v18.20.5+x64 (linux)","description":"OpenTelemetry instrumentation for `node:http` and `node:https` http client and server modules","directories":{},"sideEffects":false,"_nodeVersion":"18.20.5","dependencies":{"semver":"^7.5.2","forwarded-parse":"2.1.2","@opentelemetry/core":"1.30.1","@opentelemetry/instrumentation":"0.57.1","@opentelemetry/semantic-conventions":"1.28.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"15.1.0","nock":"13.3.8","axios":"1.7.9","lerna":"6.6.2","mocha":"10.8.2","sinon":"15.1.2","request":"2.88.2","cross-var":"1.1.0","superagent":"10.0.2","typescript":"4.4.4","@types/node":"18.6.5","@types/mocha":"10.0.10","@types/sinon":"17.0.3","@types/semver":"7.5.8","@types/superagent":"8.1.9","@opentelemetry/api":"1.9.0","request-promise-native":"1.0.9","@opentelemetry/sdk-metrics":"1.30.1","@opentelemetry/sdk-trace-base":"1.30.1","@opentelemetry/sdk-trace-node":"1.30.1","@types/request-promise-native":"1.0.21","@opentelemetry/context-async-hooks":"1.30.1"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-http_0.57.1_1736846238809_0.8567985213225349","host":"s3://npm-registry-packages-npm-production"},"readme":"# OpenTelemetry HTTP and HTTPS 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 [`http`](https://nodejs.org/api/http.html) and [`https`](https://nodejs.org/api/https.html).\n\nFor automatic instrumentation see the\n[@opentelemetry/sdk-trace-node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node) package.\n\n## Installation\n\n```bash\nnpm install --save @opentelemetry/instrumentation-http\n```\n\n## Supported Versions\n\n- Nodejs `>=14`\n\n## Usage\n\nOpenTelemetry HTTP Instrumentation allows the user to automatically collect telemetry and export it to their backend of choice, to give observability to distributed systems.\n\nTo load a specific instrumentation (HTTP in this case), specify it in the Node Tracer's configuration.\n\n```js\nconst { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');\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: [new SimpleSpanProcessor(new ConsoleSpanExporter())]\n});\n\nprovider.register();\n\nregisterInstrumentations({\n  instrumentations: [new HttpInstrumentation()],\n});\n\n```\n\nSee [examples/http](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/http) for a short example.\n\n### Http instrumentation Options\n\nHttp instrumentation has few options available to choose from. You can set the following:\n\n| Options | Type | Description |\n| ------- | ---- | ----------- |\n| [`applyCustomAttributesOnSpan`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L91) | `HttpCustomAttributeFunction` | Function for adding custom attributes |\n| [`requestHook`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#93) | `HttpRequestCustomAttributeFunction` | Function for adding custom attributes before request is handled |\n| [`responseHook`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L95) | `HttpResponseCustomAttributeFunction` | Function for adding custom attributes before response is handled |\n| [`startIncomingSpanHook`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L97) | `StartIncomingSpanCustomAttributeFunction` | Function for adding custom attributes before a span is started in incomingRequest |\n| [`startOutgoingSpanHook`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L99) | `StartOutgoingSpanCustomAttributeFunction` | Function for adding custom attributes before a span is started in outgoingRequest |\n| `ignoreIncomingRequestHook` | `IgnoreIncomingRequestFunction` | Http instrumentation will not trace all incoming requests that matched with custom function |\n| `ignoreOutgoingRequestHook` | `IgnoreOutgoingRequestFunction` | Http instrumentation will not trace all outgoing requests that matched with custom function |\n| `disableOutgoingRequestInstrumentation` | `boolean` | Set to true to avoid instrumenting outgoing requests at all. This can be helpful when another instrumentation handles outgoing requests. |\n| `disableIncomingRequestInstrumentation` | `boolean` | Set to true to avoid instrumenting incoming requests at all. This can be helpful when another instrumentation handles incoming requests. |\n| [`serverName`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L101) | `string` | The primary server name of the matched virtual host. |\n| [`requireParentforOutgoingSpans`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L103) | Boolean | Require that is a parent span to create new span for outgoing requests. |\n| [`requireParentforIncomingSpans`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L105) | Boolean | Require that is a parent span to create new span for incoming requests. |\n| [`headersToSpanAttributes`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L107) | `object` | List of case insensitive HTTP headers to convert to span attributes. Client (outgoing requests, incoming responses) and server (incoming requests, outgoing responses) headers will be converted to span attributes in the form of `http.{request\\|response}.header.header_name`, e.g. `http.response.header.content_length` |\n\n## Semantic Conventions\n\nPrior to version `0.54`, this instrumentation created spans targeting an experimental semantic convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md).\n\nThis package is capable of emitting both Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) and [Version 1.27.0](https://github.com/open-telemetry/semantic-conventions/blob/v1.27.0/docs/http/http-spans.md).\nIt is controlled using the environment variable `OTEL_SEMCONV_STABILITY_OPT_IN`, which is a comma separated list of values.\nThe values `http` and `http/dup` control this instrumentation.\nSee details for the behavior of each of these values below.\nIf neither `http` or `http/dup` is included in `OTEL_SEMCONV_STABILITY_OPT_IN`, the old experimental semantic conventions will be used by default.\n\n### Stable Semantic Conventions 1.27\n\nEnabled when `OTEL_SEMCONV_STABILITY_OPT_IN` contains `http` OR `http/dup`.\nThis is the recommended configuration, and will soon become the default behavior.\n\nFollow all requirements and recommendations of HTTP Client and Server Semantic Conventions Version 1.27.0 for [spans](https://github.com/open-telemetry/semantic-conventions/blob/v1.27.0/docs/http/http-spans.md) and [metrics](https://github.com/open-telemetry/semantic-conventions/blob/v1.27.0/docs/http/http-metrics.md), including all required and recommended attributes.\n\nMetrics Exported:\n\n- [`http.server.request.duration`](https://github.com/open-telemetry/semantic-conventions/blob/v1.27.0/docs/http/http-metrics.md#metric-httpserverrequestduration)\n- [`http.client.request.duration`](https://github.com/open-telemetry/semantic-conventions/blob/v1.27.0/docs/http/http-metrics.md#metric-httpclientrequestduration)\n\n### Upgrading Semantic Conventions\n\nWhen upgrading to the new semantic conventions, it is recommended to do so in the following order:\n\n1. Upgrade `@opentelemetry/instrumentation-http` to the latest version\n2. Set `OTEL_SEMCONV_STABILITY_OPT_IN=http/dup` to emit both old and new semantic conventions\n3. Modify alerts, dashboards, metrics, and other processes to expect the new semantic conventions\n4. Set `OTEL_SEMCONV_STABILITY_OPT_IN=http` to emit only the new semantic conventions\n\nThis will cause both the old and new semantic conventions to be emitted during the transition period.\n\n### Legacy Behavior (default)\n\nEnabled when `OTEL_SEMCONV_STABILITY_OPT_IN` contains `http/dup` or DOES NOT CONTAIN `http`.\nThis is the current default behavior.\n\nCreate HTTP client spans which implement Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md).\n\n#### Server Spans (legacy)\n\nWhen `OTEL_SEMCONV_STABILITY_OPT_IN` is not set or includes `http/dup`, this module implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md).\n\nAttributes collected:\n\n| Attribute                                   | Short Description                                                              |\n| ------------------------------------------- | ------------------------------------------------------------------------------ |\n| `ip_tcp`                                    | Transport protocol used                                                        |\n| `ip_udp`                                    | Transport protocol used                                                        |\n| `http.client_ip`                            | The IP address of the original client behind all proxies, if known             |\n| `http.flavor`                               | Kind of HTTP protocol used                                                     |\n| `http.host`                                 | The value of the HTTP host header                                              |\n| `http.method`                               | HTTP request method                                                            |\n| `http.request_content_length`               | The size of the request payload body in bytes                                  |\n| `http.request_content_length_uncompressed`  | The size of the uncompressed request payload body after transport decoding     |\n| `http.response_content_length`              | The size of the response payload body in bytes                                 |\n| `http.response_content_length_uncompressed` | The size of the uncompressed response payload body after transport decoding    |\n| `http.route`                                | The matched route (path template).                                             |\n| `http.scheme`                               | The URI scheme identifying the used protocol                                   |\n| `http.server_name`                          | The primary server name of the matched virtual host                            |\n| `http.status_code`                          | HTTP response status code                                                      |\n| `http.target`                               | The full request target as passed in a HTTP request line or equivalent         |\n| `http.url`                                  | Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]` |\n| `http.user_agent`                           | Value of the HTTP User-Agent header sent by the client                         |\n| `net.host.ip`                               | Like net.peer.ip but for the host IP. Useful in case of a multi-IP host        |\n| `net.host.name`                             | Local hostname or similar                                                      |\n| `net.host.port`                             | Like net.peer.port but for the host port                                       |\n| `net.peer.ip.`                              | Remote address of the peer (dotted decimal for IPv4 or RFC5952 for IPv6)       |\n| `net.peer.name`                             | Remote hostname or similar                                                     |\n| `net.peer.port`                             | Remote port number                                                             |\n| `net.transport`                             | Transport protocol used                                                        |\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/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-http\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-http.svg\n","publish_time":1736846239000,"maintainers":[{"name":"bogdandrutu","email":"bogdandrutu@gmail.com"},{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"}],"_cnpm_publish_time":1736846239000,"dist-tags":{"canary":"0.300.0-rc.0","latest":"0.301.2","latest-2":"0.223.2","next":"0.34.0"}}