{"name":"@opentelemetry/sdk-node","version":"0.300.0","keywords":["opentelemetry","nodejs","tracing","profiling","metrics","stats","monitoring"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/sdk-node@0.300.0","maintainers":[{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"},{"name":"overbalance","email":"overbalancedev@proton.me"},{"name":"npmjs-account","email":"npmjs-account@opentelemetry.io"},{"name":"trentm","email":"trentm@gmail.com"},{"name":"martinkuba","email":"martin@martinkuba.com"}],"homepage":"https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-sdk-node","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js/issues"},"dist":{"shasum":"f871bc1eb30b5a13b2f42a93e873c883ecf55d52","tarball":"http://registry-npm.ywwl.com/@opentelemetry/sdk-node/download/@opentelemetry/sdk-node-0.300.0.tgz","fileCount":44,"integrity":"sha512-yRaNP91ilq0m5fBCXSo7ZTR1NDd/GPu02uq0Rur2kMw7VheHwkV8i68oYt4/vM+eofRFKYCGS5B2QrgcZS/rmw==","signatures":[{"sig":"MEQCIGf0KVWmigaBuWhjIt8nZ8SnXSVhglXiCBNazId5kDCSAiAlxZsMD0cZtCFKF9bQK3TN7Z4B4o2cuukvOFY+faBvtQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIGNMEHa1paJnrjp040ImQgNrn3af61kKUr++ocm94Mv6AiEAgaNni71YG0Cp7BqepalsowQNAyxTK2E2SRJpfaiwX1o=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2fsdk-node@0.300.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":406765,"size":81553,"noattachment":false,"key":"/@opentelemetry/sdk-node/-/@opentelemetry/sdk-node-0.300.0.tgz"},"main":"./dist/index.cjs","types":"./dist/index.d.cts","engines":{"node":">=22.15.0"},"exports":{".":{"default":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"12a5817ad147c186a0e45a6637abd5abf423727a","scripts":{"lint":"eslint .","test":"nyc mocha test/**/*.test.ts","clean":"rimraf dist build","watch":"tsdown --watch --no-clean","compile":"tsdown","version":"node ../../../scripts/version-update.js","lint:fix":"eslint . --fix","align-api-deps":"node ../../../scripts/align-api-deps.mjs","peer-api-check":"node ../../../scripts/peer-api-check.mjs","prepublishOnly":"npm run compile","maint:regenerate-test-certs":"cd test/certs && ./regenerate.sh"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"c2f302c2-0b34-4c9b-90a8-fde4701579d4"}},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js.git","type":"git"},"_npmVersion":"lerna/10.0.1/node@v24.22.0+x64 (linux)","description":"OpenTelemetry SDK for Node.js","directories":{},"sideEffects":false,"_nodeVersion":"24.22.0","dependencies":{"@opentelemetry/core":"3.0.0","@opentelemetry/sdk-logs":"3.0.0","@opentelemetry/resources":"3.0.0","@opentelemetry/sdk-trace":"3.0.0","@opentelemetry/sdk-metrics":"3.0.0","@opentelemetry/configuration":"0.300.0","@opentelemetry/propagator-b3":"3.0.0","@opentelemetry/exporter-zipkin":"3.0.0","@opentelemetry/instrumentation":"0.300.0","@opentelemetry/otlp-exporter-base":"0.300.0","@opentelemetry/context-async-hooks":"3.0.0","@opentelemetry/exporter-prometheus":"0.300.0","@opentelemetry/semantic-conventions":"^1.29.0","@opentelemetry/exporter-logs-otlp-grpc":"0.300.0","@opentelemetry/exporter-logs-otlp-http":"0.300.0","@opentelemetry/otlp-grpc-exporter-base":"0.300.0","@opentelemetry/exporter-logs-otlp-proto":"0.300.0","@opentelemetry/exporter-trace-otlp-grpc":"0.300.0","@opentelemetry/exporter-trace-otlp-http":"0.300.0","@opentelemetry/exporter-trace-otlp-proto":"0.300.0","@opentelemetry/exporter-metrics-otlp-grpc":"0.300.0","@opentelemetry/exporter-metrics-otlp-http":"0.300.0","@opentelemetry/exporter-metrics-otlp-proto":"0.300.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"18.0.0","mocha":"12.0.3","sinon":"18.0.1","ts-loader":"9.5.7","typescript":"5.2.2","@types/node":"18.19.130","@types/mocha":"10.0.10","@types/sinon":"17.0.4","@opentelemetry/api":"1.10.0"},"peerDependencies":{"@opentelemetry/api":">=1.10.0 <1.11.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk-node_0.300.0_1792521533054_0.3765673383805199","host":"s3://npm-registry-packages-npm-production"},"readme":"# OpenTelemetry SDK 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 package provides the full OpenTelemetry SDK for Node.js including tracing and metrics.\n\n## Quick Start\n\n**Note: Much of OpenTelemetry JS documentation is written assuming the compiled application is run as CommonJS.**\nFor more details on ECMAScript Modules vs CommonJS, refer to [esm-support](https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/esm-support.md).\n\nTo get started you need to install `@opentelemetry/sdk-node`, a metrics and/or tracing exporter, and any appropriate instrumentation for the node modules used by your application.\n\n### Installation\n\n```sh\n$ # Install the SDK\n$ npm install @opentelemetry/sdk-node\n\n$ # Install exporters and plugins\n$ npm install \\\n    @opentelemetry/exporter-trace-otlp-proto \\ # add tracing exporters as needed\n    @opentelemetry/exporter-prometheus \\ # add metrics exporters as needed\n    @opentelemetry/instrumentation-http # add instrumentations as needed\n\n$ # or install all officially supported core and contrib plugins\n$ npm install @opentelemetry/auto-instrumentations-node\n\n```\n\n> Note: this example is for Node.js. See [examples/opentelemetry-web](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/opentelemetry-web) for a browser example.\n\n### Initialize the SDK\n\nBefore any other module in your application is loaded, you must initialize the SDK.\nIf you fail to initialize the SDK or initialize it too late, no-op implementations will be provided to any library which acquires a tracer or meter from the API.\n\nThis example uses Jaeger (via OTLP) and Prometheus, but exporters exist for [other tracing backends][other-tracing-backends].\nOTLP in particular is widely supported by a wide-variety of backends.\nAs shown in the installation instructions, exporters passed to the SDK must be installed alongside `@opentelemetry/sdk-node`.\n\n```javascript\nconst opentelemetry = require(\"@opentelemetry/sdk-node\");\nconst { OTLPTraceExporter } = require(\"@opentelemetry/exporter-trace-otlp-proto\");\nconst { PrometheusExporter } = require(\"@opentelemetry/exporter-prometheus\");\nconst {\n  getNodeAutoInstrumentations,\n} = require(\"@opentelemetry/auto-instrumentations-node\");\n\nconst otlpExporter = new OTLPTraceExporter();\nconst prometheusExporter = new PrometheusExporter();\n\nconst sdk = new opentelemetry.NodeSDK({\n  // Optional - if omitted, the tracing SDK will be initialized from environment variables\n  traceExporter: otlpExporter,\n  // Optional - If omitted, the metrics SDK will not be initialized\n  metricReader: prometheusExporter,\n  // Optional - you can use the metapackage or load each instrumentation individually\n  instrumentations: [getNodeAutoInstrumentations()],\n  // See the Configuration section below for additional  configuration options\n});\n\nsdk.start();\n\n// You can also use the shutdown method to gracefully shut down the SDK before process shutdown\n// or on some operating system signal.\nconst process = require(\"process\");\nprocess.on(\"SIGTERM\", () => {\n  sdk\n    .shutdown()\n    .then(\n      () => console.log(\"SDK shut down successfully\"),\n      (err) => console.log(\"Error shutting down SDK\", err)\n    )\n    .finally(() => process.exit(0));\n});\n```\n\n## Configuration\n\nBelow is a full list of configuration options which may be passed into the `NodeSDK` constructor;\n\n### autoDetectResources\n\nDetect resources automatically from the environment using the default resource detectors. Default `true`.\n\n### contextManager\n\nUse a custom context manager. Default: [AsyncLocalStorageContextManager](../../../packages/opentelemetry-context-async-hooks/README.md)\n\n### textMapPropagator\n\nUse a custom propagator. Default: [CompositePropagator](../../../packages/opentelemetry-core/src/propagation/composite.ts) using [W3C Trace Context](../../../packages/opentelemetry-core/README.md#w3ctracecontextpropagator-propagator) and [Baggage](../../../packages/opentelemetry-core/README.md#baggage-propagator)\n\n### logRecordProcessor\n\nDeprecated, please use [logRecordProcessors](#logrecordprocessors) instead.\n\n### logRecordProcessors\n\nAn array of log record processors to register to the logger provider.\n\n### metricReader\n\nAdd a [MetricReader](../../../packages/sdk-metrics/src/export/MetricReader.ts)\nthat will be passed to the `MeterProvider`. If `metricReader` is not configured,\nthe metrics SDK will not be initialized and registered.\n\n### views\n\nA list of views to be passed to the `MeterProvider`.\nAccepts an array of [View](../../../packages/sdk-metrics/src/view/View.ts)-instances.\nThis parameter can be used to configure explicit bucket sizes of histogram metrics.\n\n### instrumentations\n\nConfigure instrumentations. By default none of the instrumentation is enabled,\nif you want to enable them you can use either [metapackage](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/auto-instrumentations-node)\nor configure each instrumentation individually.\n\n### resource\n\nA [Resource](https://opentelemetry.io/docs/specs/otel/resource/sdk/) to associate with generated telemetry.\nThis resource will be use as the basis for additional resource attributes determined by [resource detectors](#resourcedetectors).\nSee also the [`autoDetectResources` setting](#autodetectresources).\n\nIf not specified, the [default resource](https://opentelemetry.io/docs/specs/semconv/resource/#semantic-attributes-with-sdk-provided-default-value) will be used.\n\n> [!WARNING]\n> If specifying the `resource` option, it is recommended that the default resource be included.\n> Otherwise the important `service.name` and `telemetry.sdk.*` resource attributes might not be included on telemetry,\n> which can adversely impact downstream processing or visualization.\n> The default resource can be include as follows:\n>\n> ```js\n> import { NodeSDK } from '@opentelemetry/sdk-node';\n> import { resourceFromAttributes, defaultResource } from '@opentelemetry/resources';\n> const sdk = new NodeSDK({\n>   resource: defaultResource().merge(\n>     resourceFromAttributes({\n>       'my.custom.attr': 'some value',\n>     })\n>   ),\n>   // ...\n> });\n> ```\n>\n> Alternatively, consider setting custom resource attributes via the\n> [`OTEL_RESOURCE_ATTRIBUTES`](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration)\n> environment variable.\n\n### resourceDetectors\n\nConfigure resource detectors.\nIf not specified, then detectors will be determined from the `OTEL_NODE_RESOURCE_DETECTORS` environment variable.\nIf neither is specified, the default set of detectors is `[serviceInstanceIdDetector, processDetector, hostDetector, osDetector, envDetector]`.\nNOTE: In order to enable the detection, the parameter `autoDetectResources` has to be `true`.\n\n`OTEL_NODE_RESOURCE_DETECTORS` is a comma-separated list of the following detector names:\n\n- `host`\n- `os`\n- `process`\n- `serviceinstance` - provides the `service.instance.id` attribute\n- `env` - reads attributes from `OTEL_RESOURCE_ATTRIBUTES` and `OTEL_SERVICE_NAME`\n- `all` - enable all resource detectors above\n  - **NOTE:** future versions of `@opentelemetry/sdk-node` may include additional detectors that will be covered by this scope.\n- `none` - disable resource detection\n\nFor example, to enable only the `process` and `env` detectors:\n\n```shell\nexport OTEL_NODE_RESOURCE_DETECTORS=\"process,env\"\n```\n\nDetectors are processed in the order they are defined. Attributes from a later detector wins.\nYou typically want the 'env' detector to be last, so that attributes explicitly set by `OTEL_RESOURCE_ATTRIBUTES` will win over the same attribute from an earlier detector.\nFor example with `OTEL_RESOURCE_ATTRIBUTES=\"service.instance.id=custom-name\"` and `OTEL_NODE_RESOURCE_DETECTORS=env,serviceinstance` the \"custom-name\" value will be lost to the `service.instance.id` value from the \"serviceinstance\" detector.\n\n### sampler\n\nConfigure a custom sampler. By default, all traces will be sampled.\n\n### spanProcessor\n\nDeprecated, please use [spanProcessors](#spanprocessors) instead.\n\n### spanProcessors\n\nAn array of span processors to register to the tracer provider.\n\n### traceExporter\n\nConfigure a trace exporter. If an exporter is configured, it will be used with a [BatchSpanProcessor](../../../packages/sdk-trace/src/platform/node/export/BatchSpanProcessor.ts). If an exporter OR span processor is not configured programmatically, this package will auto setup the default `otlp` exporter  with `http/protobuf` protocol with a `BatchSpanProcessor`.\n\n### spanLimits\n\nConfigure tracing parameters. These are the same trace parameters used to [configure a tracer](../../../packages/sdk-trace/src/types.ts#L20).\n\n### serviceName\n\nConfigure the [service name](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/service.md#service-name).\n\n## Disable the SDK from the environment\n\nDisable the SDK by setting the `OTEL_SDK_DISABLED` environment variable to `true`.\n\n## Configure log level from the environment\n\nSet the log level by setting the `OTEL_LOG_LEVEL` environment variable to enums:\n\n- `NONE`,\n- `ERROR`,\n- `WARN`,\n- `INFO`,\n- `DEBUG`,\n- `VERBOSE`,\n- `ALL`.\n\nThe default level is `INFO`.\n\n## Configure Exporters from environment\n\nThis is an alternative to programmatically configuring an exporter or span processor. For traces this package will auto setup the default `otlp` exporter with `http/protobuf` protocol if `traceExporter` or `spanProcessor` hasn't been passed into the `NodeSDK` constructor.\n\n### Exporters\n\n| Environment variable | Description                                                                                                                                                              |\n| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| OTEL_TRACES_EXPORTER | List of exporters to be used for tracing, separated by commas. Options include `otlp`, `zipkin`, and `none`. Default is `otlp`. `none` means no autoconfigured exporter. |\n| OTEL_LOGS_EXPORTER   | List of exporters to be used for logging, separated by commas. Options include `otlp`, `console` and `none`. Default is `otlp`. `none` means no autoconfigured exporter. |\n\n### OTLP Exporter\n\n| Environment variable                | Description                                                                                                                                                  |\n| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| OTEL_EXPORTER_OTLP_PROTOCOL         | The transport protocol to use on OTLP trace, metric, and log requests. Options include `grpc`, `http/protobuf`, and `http/json`. Default is `http/protobuf`. |\n| OTEL_EXPORTER_OTLP_TRACES_PROTOCOL  | The transport protocol to use on OTLP trace requests. Options include `grpc`, `http/protobuf`, and `http/json`. Default is `http/protobuf`.                  |\n| OTEL_EXPORTER_OTLP_METRICS_PROTOCOL | The transport protocol to use on OTLP metric requests. Options include `grpc`, `http/protobuf`, and `http/json`. Default is `http/protobuf`.                 |\n| OTEL_EXPORTER_OTLP_LOGS_PROTOCOL    | The transport protocol to use on OTLP log requests. Options include `grpc`, `http/protobuf`, and `http/json`. Default is `http/protobuf`.                    |\n| OTEL_METRICS_EXPORTER               | Metrics exporter to be used. options are `otlp`, `prometheus`, `console` or `none`. Default is `otlp`.                                                       |\n| OTEL_METRIC_EXPORT_INTERVAL         | The export interval when using a push Metric Reader. Default is `60000`.                                                                                     |\n| OTEL_METRIC_EXPORT_TIMEOUT          | The export timeout when using a push Metric Reader. Default is `30000`.                                                                                      |\n\nAdditionally, you can specify other applicable environment variables that apply to each exporter such as the following:\n\n- [OTLP exporter environment configuration](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options)\n- [Zipkin exporter environment configuration](https://github.com/open-telemetry/opentelemetry-specification/blob/6ce62202e5407518e19c56c445c13682ef51a51d/specification/sdk-environment-variables.md#zipkin-exporter)\n\n## Enable OpenTelemetry SDK internal metrics from environment\n\nOpenTelemetry defines [metrics for monitoring SDK components](https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics/).\nUntil this spec is stabilized, the following environment variable must be used\nto enable these metrics:\n\n```bash\nOTEL_NODE_EXPERIMENTAL_SDK_METRICS=true\n```\n\nCurrently a subset of the specified metrics are implemented. See the following\nlinkes for details:\n\n- Metric reader metrics: [MetricReaderMetrics](../../../packages//sdk-metrics/src/export/MetricReaderMetrics.ts)\n- Logger metrics: [LoggerMetrics.ts](../sdk-logs/src/LoggerMetrics.ts)\n- Span metrics: [TracerMetrics.ts](../../../packages/sdk-trace/src/TracerMetrics.ts)\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/sdk-node\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fsdk-node.svg\n[other-tracing-backends]: https://github.com/open-telemetry/opentelemetry-js#trace-exporters\n","publish_time":1792521533145,"_cnpm_publish_time":1792521533145,"dist-tags":{"canary":"0.300.0-rc.0","latest":"0.301.0","next":"0.34.0"}}