{"name":"@opentelemetry/configuration","version":"0.213.0","keywords":["opentelemetry","configuration"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/configuration@0.213.0","maintainers":[{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"}],"homepage":"https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/configuration","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js/issues"},"dist":{"shasum":"c722750287029fae09318c017e4f229902650a9a","tarball":"http://registry-npm.ywwl.com/@opentelemetry/configuration/download/@opentelemetry/configuration-0.213.0.tgz","fileCount":42,"integrity":"sha512-MfVgZiUuwL1d3bPPvXcEkVHGTGNUGoqGK97lfwBuRoKttcVGGqDyxTCCVa5MGbirtBQkUTysXMBUVWPaq7zbWw==","signatures":[{"sig":"MEUCIQC5bAZP7VA+2fK6YKHC86xs2J8tpOaOJOpuJGUjnnIOKgIgWDe8jxsepVn1jp1qwitRkpw/H1IKYLxw0brNWYuWZh0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2fconfiguration@0.213.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":326467,"size":53353,"noattachment":false,"key":"/@opentelemetry/configuration/-/@opentelemetry/configuration-0.213.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":"^18.19.0 || >=20.6.0"},"gitHead":"541e1b4ad83ad2093459794a18283228fe58d199","scripts":{"lint":"eslint . --ext .ts","test":"nyc mocha test/**/*.test.ts","clean":"tsc --build --clean","watch":"tsc --build --watch","compile":"tsc --build","version":"node ../../../scripts/version-update.js","lint:fix":"eslint . --ext .ts --fix","prewatch":"npm run precompile","align-api-deps":"node ../../../scripts/align-api-deps.js","peer-api-check":"node ../../../scripts/peer-api-check.js","prepublishOnly":"npm run compile"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:2d094cca-73e2-442c-94ea-74a30988c6a0"}},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js.git","type":"git"},"_npmVersion":"lerna/9.0.4/node@v24.13.1+x64 (linux)","description":"OpenTelemetry Configuration","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","dependencies":{"yaml":"^2.0.0","@opentelemetry/core":"2.6.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"17.1.0","mocha":"11.7.5","sinon":"18.0.1","ts-loader":"9.5.4","typescript":"5.0.4","@types/node":"18.19.130","@types/mocha":"10.0.10","@types/sinon":"17.0.4","@opentelemetry/api":"^1.9.0"},"peerDependencies":{"@opentelemetry/api":"^1.9.0"},"_npmOperationalInternal":{"tmp":"tmp/configuration_0.213.0_1772577300619_0.24099381193566893","host":"s3://npm-registry-packages-npm-production"},"readme":"# OpenTelemetry Declarative Configuration\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 implements the [OpenTelemetry declarative configuration](https://github.com/open-telemetry/opentelemetry-configuration) specification for Node.js. It parses configuration from a YAML file or environment variables and produces a `ConfigurationModel` that the OpenTelemetry SDK uses to initialize providers.\n\n## Installation\n\n```sh\nnpm install @opentelemetry/configuration\n```\n\n## Usage\n\n`createConfigFactory()` selects the configuration source automatically:\n\n- If `OTEL_CONFIG_FILE` points to a valid `.yaml`/`.yml` file, configuration is read from that file.\n- Otherwise, configuration is assembled from standard OpenTelemetry environment variables.\n\n```typescript\nimport { createConfigFactory } from '@opentelemetry/configuration';\n\nconst factory = createConfigFactory();\nconst config = factory.getConfigModel();\n```\n\n### YAML file configuration\n\nSet `OTEL_CONFIG_FILE` to the path of your configuration file:\n\n```sh\nOTEL_CONFIG_FILE=./otel-config.yaml node app.js\n```\n\nExample:\n\n```yaml\nfile_format: \"1.0\"\nresource:\n  attributes:\n    - name: service.name\n      value: my-service\ntracer_provider:\n  processors:\n    - batch:\n        exporter:\n          otlp_http:\n            endpoint: http://localhost:4318/v1/traces\n```\n\nEnvironment variable substitution is supported using `${VAR_NAME}`, `${VAR_NAME:-default}`, `${env:VAR_NAME}`, and `${env:VAR_NAME:-default}` syntax. Use `$$` for a literal `$`.\n\n```yaml\ntracer_provider:\n  processors:\n    - batch:\n        exporter:\n          otlp_http:\n            endpoint: ${OTEL_EXPORTER_ENDPOINT:-http://localhost:4318}/v1/traces\n```\n\n### Environment variable configuration\n\nWhen no config file is set, the factory reads from the standard OpenTelemetry SDK environment variables. The full set of variables this package consumes:\n\n| Variable | Description |\n| --- | --- |\n| `OTEL_SDK_DISABLED` | Disable the SDK entirely |\n| `OTEL_LOG_LEVEL` | Internal SDK log level |\n| `OTEL_SERVICE_NAME` | Service name resource attribute |\n| `OTEL_RESOURCE_ATTRIBUTES` | Comma-separated resource attributes |\n| `OTEL_NODE_RESOURCE_DETECTORS` | Resource detectors to enable (`env`, `host`, `os`, `process`, `serviceinstance`, `all`, `none`) |\n| `OTEL_PROPAGATORS` | Propagators: `tracecontext`, `baggage`, `b3`, `b3multi` |\n| `OTEL_TRACES_EXPORTER` | Traces exporter(s): `otlp`, `console`, `none` |\n| `OTEL_METRICS_EXPORTER` | Metrics exporter(s): `otlp`, `prometheus`, `console`, `none` |\n| `OTEL_LOGS_EXPORTER` | Logs exporter(s): `otlp`, `console`, `none` |\n| `OTEL_TRACES_SAMPLER` | Sampler name (e.g. `parentbased_always_on`, `traceidratio`) |\n| `OTEL_TRACES_SAMPLER_ARG` | Sampler argument (e.g. ratio value) |\n| `OTEL_EXPORTER_OTLP_ENDPOINT` | OTLP endpoint (all signals) |\n| `OTEL_EXPORTER_OTLP_HEADERS` | OTLP headers (all signals) |\n| `OTEL_EXPORTER_OTLP_PROTOCOL` | OTLP protocol: `grpc`, `http/protobuf`, `http/json` |\n| `OTEL_EXPORTER_OTLP_TIMEOUT` | OTLP request timeout (all signals) |\n| `OTEL_EXPORTER_OTLP_COMPRESSION` | OTLP compression (all signals): `gzip`, `none` |\n| `OTEL_EXPORTER_OTLP_CERTIFICATE` | OTLP server CA certificate file (all signals) |\n| `OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE` | OTLP client certificate file for mTLS (all signals) |\n| `OTEL_EXPORTER_OTLP_CLIENT_KEY` | OTLP client private key file for mTLS (all signals) |\n| `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | Per-signal override (traces) |\n| `OTEL_EXPORTER_OTLP_TRACES_HEADERS` | Per-signal override (traces) |\n| `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL` | Per-signal override (traces) |\n| `OTEL_EXPORTER_OTLP_TRACES_TIMEOUT` | Per-signal override (traces) |\n| `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION` | Per-signal override (traces) |\n| `OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE` | Per-signal override (traces) |\n| `OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE` | Per-signal override (traces) |\n| `OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY` | Per-signal override (traces) |\n| `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` | Per-signal override (metrics) |\n| `OTEL_EXPORTER_OTLP_METRICS_HEADERS` | Per-signal override (metrics) |\n| `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` | Per-signal override (metrics) |\n| `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` | Per-signal override (metrics) |\n| `OTEL_EXPORTER_OTLP_METRICS_COMPRESSION` | Per-signal override (metrics) |\n| `OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE` | Per-signal override (metrics) |\n| `OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE` | Per-signal override (metrics) |\n| `OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY` | Per-signal override (metrics) |\n| `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | Metric temporality preference: `cumulative`, `delta`, `lowmemory` |\n| `OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION` | Default histogram aggregation: `explicit_bucket_histogram`, `base2_exponential_bucket_histogram` |\n| `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` | Per-signal override (logs) |\n| `OTEL_EXPORTER_OTLP_LOGS_HEADERS` | Per-signal override (logs) |\n| `OTEL_EXPORTER_OTLP_LOGS_PROTOCOL` | Per-signal override (logs) |\n| `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT` | Per-signal override (logs) |\n| `OTEL_EXPORTER_OTLP_LOGS_COMPRESSION` | Per-signal override (logs) |\n| `OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE` | Per-signal override (logs) |\n| `OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE` | Per-signal override (logs) |\n| `OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY` | Per-signal override (logs) |\n| `OTEL_EXPORTER_PROMETHEUS_HOST` | Prometheus exporter bind host |\n| `OTEL_EXPORTER_PROMETHEUS_PORT` | Prometheus exporter bind port |\n| `OTEL_METRIC_EXPORT_INTERVAL` | Periodic metric reader export interval (ms) |\n| `OTEL_METRIC_EXPORT_TIMEOUT` | Periodic metric reader export timeout (ms) |\n| `OTEL_METRICS_EXEMPLAR_FILTER` | Exemplar filter: `always_on`, `always_off`, `trace_based` |\n| `OTEL_BSP_SCHEDULE_DELAY` | Batch span processor: schedule delay (ms) |\n| `OTEL_BSP_EXPORT_TIMEOUT` | Batch span processor: export timeout (ms) |\n| `OTEL_BSP_MAX_QUEUE_SIZE` | Batch span processor: max queue size |\n| `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` | Batch span processor: max export batch size |\n| `OTEL_BLRP_SCHEDULE_DELAY` | Batch log record processor: schedule delay (ms) |\n| `OTEL_BLRP_EXPORT_TIMEOUT` | Batch log record processor: export timeout (ms) |\n| `OTEL_BLRP_MAX_QUEUE_SIZE` | Batch log record processor: max queue size |\n| `OTEL_BLRP_MAX_EXPORT_BATCH_SIZE` | Batch log record processor: max export batch size |\n| `OTEL_ATTRIBUTE_COUNT_LIMIT` | Default max attributes per span/log/event/link |\n| `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT` | Default max attribute value length |\n| `OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT` | Max attributes per span |\n| `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` | Max span attribute value length |\n| `OTEL_SPAN_EVENT_COUNT_LIMIT` | Max events per span |\n| `OTEL_SPAN_LINK_COUNT_LIMIT` | Max links per span |\n| `OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT` | Max attributes per span event |\n| `OTEL_LINK_ATTRIBUTE_COUNT_LIMIT` | Max attributes per span link |\n| `OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT` | Max attributes per log record |\n| `OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT` | Max log record attribute value length |\n\nSee [`src/EnvironmentConfigFactory.ts`](src/EnvironmentConfigFactory.ts) for the exact parsing logic.\n\n## Exported types\n\nTypes exported from this package that model configuration data use a `ConfigModel` suffix (e.g. `SamplerConfigModel`, `SpanExporterConfigModel`) rather than their schema name (e.g. `Sampler`, `SpanExporter`). This keeps them from colliding with the SDK runtime types of the same name. The root type is `ConfigurationModel`.\n\nInternally the package uses the schema names from `src/generated/types.ts`; the renaming happens at export time in `src/index.ts`. Follow this convention when adding new exports.\n\n## Development\n\n### Generated files\n\n`src/generated/` is auto-generated — do not edit manually. It contains:\n\n- `types.ts` — TypeScript interfaces derived from the JSON schema (via `json-schema-to-typescript`)\n- `validator.js` — Pre-compiled ajv validator (ahead-of-time compiled from the schema at build time; eliminates runtime `ajv.compile()`)\n- `validator.d.ts` — TypeScript declarations for `validator.js`\n\n### Regenerating after a schema version bump\n\n1. Update the `CONFIG_VERSION` constant in `scripts/generate-config.js`\n2. Run from this package directory:\n\n   ```sh\n   npm run generate:config\n   ```\n\n3. Review the diff in `src/generated/types.ts` and `src/generated/validator.js`\n4. Update `SUPPORTED_FILE_FORMAT_MAJOR` / `SUPPORTED_FILE_FORMAT_MINOR` in `src/FileConfigFactory.ts` if the new schema version is outside the currently-supported range\n5. Update `EnvironmentConfigFactory.ts` and `utils.ts` if new fields need env var mapping\n\nThe generation script (`scripts/generate-config.js`) handles several post-processing steps:\n\n- Renames the root type from `OpenTelemetryConfiguration` to `ConfigurationModel`\n- Makes `file_format` optional (required at parse time but not needed when constructing the model in code)\n- Removes the duplicate type declarations that `json-schema-to-typescript` emits for structurally-identical sub-schemas (e.g. the second `GrpcTls`/`HttpTls`)\n- Produces a pre-compiled ajv validator (`validator.js` + `validator.d.ts`) for use at runtime\n\n### Defaults\n\nBoth config paths apply the same spec-defined defaults so consumers see consistent behaviour regardless of config source:\n\n| Field | Default |\n| --- | --- |\n| `disabled` | `false` |\n| `log_level` | `info` |\n| `attribute_limits.attribute_count_limit` | `128` |\n\n`FileConfigFactory` applies these via `applyConfigDefaults()` after schema validation. `EnvironmentConfigFactory` applies them via `initializeDefaultConfiguration()` in the constructor, then overlays env var values on top.\n\nOne intentional exception in both paths: `AttributeNameValue.type` is **not** defaulted even though the spec says \"if omitted, string is used\". This is a semantic default for SDK code interpreting resource attributes, not a config-parser concern. SDK code reading `resource.attributes` should apply `attr.type ?? 'string'` at the point of use.\n\n## Supported schema versions\n\n- `1.0`\n- `1.1`\n\nFor a per-field view of which schema fields the SDK currently applies, see\nthe JS row in the cross-SDK [language support status][lss] doc maintained in\nthe `opentelemetry-configuration` repo. That doc is the source of truth for\ndeclarative-config conformance across all SDKs.\n\n[lss]: https://github.com/open-telemetry/opentelemetry-configuration/blob/main/language-support-status.md#js-\n\n## Useful links\n\n- [OpenTelemetry Declarative Configuration Specification](https://github.com/open-telemetry/opentelemetry-configuration)\n- [OpenTelemetry for Node.js](https://github.com/open-telemetry/opentelemetry-js)\n- [OpenTelemetry Community](https://opentelemetry.io/)\n\n## License\n\nApache 2.0 - See [LICENSE][license-url] for more information.\n\n[npm-url]: https://www.npmjs.com/package/@opentelemetry/configuration\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fconfiguration.svg\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","publish_time":1772577300774,"_cnpm_publish_time":1772577300774,"dist-tags":{"canary":"0.300.0-rc.0","latest":"0.301.0"}}