{"_id":"@aezequiel/instrumentation-xml-http-request","name":"@aezequiel/instrumentation-xml-http-request","dist-tags":{"latest":"0.205.0"},"versions":{"0.205.0":{"name":"@aezequiel/instrumentation-xml-http-request","version":"0.205.0","description":"OpenTelemetry instrumentation for XMLHttpRequest http client in web browsers","main":"build/src/index.js","module":"build/esm/index.js","esnext":"build/esnext/index.js","types":"build/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/open-telemetry/opentelemetry-js.git"},"scripts":{"prepublishOnly":"npm run compile","compile":"tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json","clean":"tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json","lint":"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix","version":"node ../../../scripts/version-update.js","tdd":"karma start","test:browser":"karma start --single-run","watch":"tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json","precompile":"lerna run version --scope @aezequiel/instrumentation-xml-http-request --include-dependencies","prewatch":"node ../../../scripts/version-update.js","peer-api-check":"node ../../../scripts/peer-api-check.js","align-api-deps":"node ../../../scripts/align-api-deps.js"},"keywords":["opentelemetry","browser","tracing","profiling","metrics","XMLHttpRequest","stats"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","engines":{"node":"^18.19.0 || >=20.6.0"},"publishConfig":{"access":"public"},"devDependencies":{"@babel/core":"7.27.1","@babel/preset-env":"7.27.2","@opentelemetry/api":"1.9.0","@opentelemetry/context-zone":"2.1.0","@opentelemetry/propagator-b3":"2.1.0","@opentelemetry/sdk-trace-base":"2.1.0","@types/mocha":"10.0.10","@types/node":"18.6.5","@types/sinon":"17.0.4","@types/webpack-env":"1.16.3","babel-loader":"10.0.0","babel-plugin-istanbul":"7.0.1","karma":"6.4.4","karma-chrome-launcher":"3.1.0","karma-coverage":"2.2.1","karma-mocha":"2.0.1","karma-spec-reporter":"0.0.36","karma-webpack":"5.0.1","lerna":"6.6.2","mocha":"11.7.2","nyc":"17.1.0","sinon":"18.0.1","ts-loader":"9.5.4","typescript":"5.0.4","webpack":"5.101.3","webpack-cli":"6.0.1"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"dependencies":{"@opentelemetry/core":"2.1.0","@opentelemetry/instrumentation":"0.205.0","@opentelemetry/sdk-trace-web":"2.1.0","@opentelemetry/semantic-conventions":"^1.29.0"},"homepage":"https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-xml-http-request","sideEffects":false,"gitHead":"3e1aba318d701f74680e00dc7467e933eb82dc8e","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js/issues"},"_id":"@aezequiel/instrumentation-xml-http-request@0.205.0","_nodeVersion":"16.10.0","_npmVersion":"7.24.0","dist":{"integrity":"sha512-L7ieYrnLJ4zABMwyqjJh4RrzASZP6YAk8P4IHjhShwuVfFvEtDMzZtMnHydA8HzaUwZ9k5rw3E0RFaCeVRsWEQ==","shasum":"8cb3f54558a44d20d7ed5c634cc7de11ec93e5f2","tarball":"https://registry.npmjs.org/@aezequiel/instrumentation-xml-http-request/-/instrumentation-xml-http-request-0.205.0.tgz","fileCount":75,"unpackedSize":310935,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC5GPB4yWTe7H6FZYccE/CwxNHcA9pLQuDqE+qEvR5MPwIhAOlF26+Br13U1Z+Wn/aNbgUlBsWU/MIq7eGjmGd1i+8l"}]},"_npmUser":{"name":"aezequiel","email":"agustin.bua@gmail.com"},"directories":{},"maintainers":[{"name":"aezequiel","email":"agustin.bua@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/instrumentation-xml-http-request_0.205.0_1758970608543_0.5979570197264903"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-27T10:56:48.452Z","0.205.0":"2025-09-27T10:56:48.756Z","modified":"2025-09-27T10:56:49.043Z"},"maintainers":[{"name":"aezequiel","email":"agustin.bua@gmail.com"}],"description":"OpenTelemetry instrumentation for XMLHttpRequest http client in web browsers","homepage":"https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-xml-http-request","keywords":["opentelemetry","browser","tracing","profiling","metrics","XMLHttpRequest","stats"],"repository":{"type":"git","url":"git+https://github.com/open-telemetry/opentelemetry-js.git"},"author":{"name":"OpenTelemetry Authors"},"bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js/issues"},"license":"Apache-2.0","readme":"# OpenTelemetry XMLHttpRequest Instrumentation for web\n\n[![NPM Published Version][npm-img]][npm-url]\n[![Apache License][license-image]][license-image]\n\n**Note: This is an experimental package. New releases may include breaking changes.**\n\nThis module provides auto instrumentation for web using XMLHttpRequest.\n\n## Installation\n\n```bash\nnpm install --save @opentelemetry/instrumentation-xml-http-request\n```\n\n## Usage\n\n```js\nimport {\n  ConsoleSpanExporter,\n  SimpleSpanProcessor,\n  WebTracerProvider,\n} from '@opentelemetry/sdk-trace-web';\nimport { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';\nimport { ZoneContextManager } from '@opentelemetry/context-zone';\nimport { registerInstrumentations } from '@opentelemetry/instrumentation';\n\nconst providerWithZone = new WebTracerProvider({\n  spanProcessors: [new SimpleSpanProcessor(new ConsoleSpanExporter())]\n});\n\nproviderWithZone.register({\n  contextManager: new ZoneContextManager(),\n});\n\nregisterInstrumentations({\n  instrumentations: [\n    new XMLHttpRequestInstrumentation({\n      propagateTraceHeaderCorsUrls: ['http://localhost:8090']\n    }),\n  ],\n});\n\n\nconst webTracerWithZone = providerWithZone.getTracer('default');\n\n/////////////////////////////////////////\n\n// or plugin can be also initialised separately and then set the tracer provider or meter provider\nconst xmlHttpRequestInstrumentation = new XMLHttpRequestInstrumentation({\n  propagateTraceHeaderCorsUrls: ['http://localhost:8090']\n});\nconst providerWithZone = new WebTracerProvider();\nproviderWithZone.register({\n  contextManager: new ZoneContextManager(),\n});\nxmlHttpRequestInstrumentation.setTracerProvider(providerWithZone);\n/////////////////////////////////////////\n\n\n// and some test\nconst req = new XMLHttpRequest();\nreq.open('GET', 'http://localhost:8090/xml-http-request.js', true);\nreq.send();\n```\n\n### XHR Instrumentation options\n\nXHR instrumentation plugin has few options available to choose from. You can set the following:\n\n| Options                       | Type                         | Description |\n| ----------------------------- | ---------------------------- | ----------- |\n| `applyCustomAttributesOnSpan` | `XHRCustomAttributeFunction` | Function for adding custom attributes |\n| `ignoreNetworkEvents`         | boolean                      | Disable network events being added as span events (network events are added by default) |\n| `measureRequestSize`          | boolean                      | Measure outgoing request length (outgoing request length is not measured by default) |\n| `semconvStabilityOptIn`       | string                       | A comma-separated string of tokens as described for `OTEL_SEMCONV_STABILITY_OPT_IN` in the [HTTP semantic convention stability migration](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md) guide. See the \"Semantic Conventions\" section below. |\n\n## Semantic Conventions\n\nUp to and including v0.200.0, `instrumentation-xml-http-request` generates telemetry using [Semantic Conventions v1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md).\n\nHTTP semantic conventions (semconv) were stabilized in semconv v1.23.0, and a [migration process](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md#http-semantic-convention-stability-migration) was defined. `instrumentation-xml-http-request` versions 0.201.0 and later include support for migrating to stable HTTP semantic conventions, as described below. The intent is to provide an approximate 6 month time window for users of this instrumentation to migrate to the new HTTP semconv, after which a new minor version will change to use the *new* semconv by default and drop support for the old semconv. See the [HTTP semconv migration plan for OpenTelemetry JS instrumentations](https://github.com/open-telemetry/opentelemetry-js/issues/5646).\n\nTo select which semconv version(s) is emitted from this instrumentation, use the `semconvStabilityOptIn` configuration option. This option works [as described for `OTEL_SEMCONV_STABILITY_OPT_IN`](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md):\n\n- `http`: emit the new (stable) v1.23.0 semantics\n- `http/dup`: emit **both** the old v1.7.0 and the new (stable) v1.23.0 semantics\n- By default, if `semconvStabilityOptIn` includes neither of the above tokens, the old v1.7.0 semconv is used.\n\n**Span status:** When the stable semconv is selected, the [span status](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#status) is set to ERROR when the response status code is `>=400` or when the response fails with an 'error' or 'timeout' XHR event. When just the old semconv is select, the span status is not set.\n\n**Span attributes:**\n\n| v1.7.0 semconv         | v1.23.0 semconv                    | Notes |\n| ---------------------- | ---------------------------------- | ----- |\n| `http.method`          | `http.request.method`              | HTTP request method. With v1.23.0 semconv [`http.request.method_original` may also be included](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#common-attributes). |\n| `http.url`             | `url.full`                         | Full HTTP request URL |\n| `http.host`            | `server.address` and `server.port` | The hostname and port of the request URL |\n| `http.status_code`     | `http.response.status_code`        | HTTP response status code |\n| `http.request_content_length_uncompressed` | `http.request.body.size` | This is only added if `measureRequestSize` is `true`. |\n| `http.response_content_length_uncompressed` | (not included) | Stable HTTP semconv would use `http.response.body.size`, but this is an [`Opt-In` attribute](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#http-client), so would require adding a configuration option to this instrumentation to enable. |\n| `http.response_content_length` | (not included)              | Stable HTTP semconv would use `http.response.header.<key>`, but this is an [`Opt-In` attribute](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#http-client), so would require adding a configuration option to this instrumentation to enable. |\n| (no equivalent)        | `error.type`                       | The response status (as a string), if the response status was `>=400`, or one of these possible request errors: 'timeout' and 'error'.|\n| `http.user_agent`      | (not included)                     | Stable HTTP semconv would use `user_agent.original`, but this is an [`Opt-In` attribute](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#http-client), so would require adding a configuration option to this instrumentation to enable. |\n| `http.scheme`          | (not included)                     | Stable HTTP semconv would use `url.scheme`, but this is an [`Opt-In` attribute](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#http-client), so would require adding a configuration option to this instrumentation to enable. |\n| `http.status_text`     | (not included)                     | This is no longer a documented semantic conventions attribute. |\n\n## Example Screenshots\n\n![Screenshot of the running example](images/main.jpg)\n![Screenshot of the running example](images/request.jpg)\n![Screenshot of the running example](images/cors.jpg)\n\nSee [examples/tracer-web](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/tracer-web) for a short example.\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-xml-http-request\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-xml-http-request.svg\n","readmeFilename":"README.md","_rev":"1-47c54f20917cf9a35fbaf5153daad1ea"}