opentelemetry-js
opentelemetry-js copied to clipboard
[sdk-node] implement enviornment configuration for auto-paired `PeriodicExportingMetricReader`
Description
The specification defines that PeriodicExporingMetricReaders that are auto-paired with an exporter can be configured via environment variables.
For this issue to be considered done we need to:
- [ ] implement #4551
- [ ] in
@opentelmetry/sdk-node, where the automatic pairing from #4551 is implemented, read the env vars fromOTEL_METRIC_EXPORT_INTERVAL/OTEL_METRIC_EXPORT_TIMEOUTand configure the auto-pairedPeriodicExportingMetricReaderaccordingly. Use defaults if the env vars are unset.
Additional infomation
Original feature-request:
- #4562
The specification defines that
PeriodicExporingMetricReaders that are auto-paired with an exporter can be configured via environment variables.
Does the spec actually say anything about this only applying when auto-paired? The BatchSpanProcessor reads from the environment variables directly https://github.com/open-telemetry/opentelemetry-js/blob/31eb60dc99dc066cf2085864f2727eb29ee76e91/packages/opentelemetry-sdk-trace-base/src/export/BatchSpanProcessorBase.ts#L55-L58
so the environment variables are applied globally. I'm guessing this is related to the yaml config file conversation and the related concern around precedence
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
The specification defines that
PeriodicExporingMetricReaders that are auto-paired with an exporter can be configured via environment variables.Does the spec actually say anything about this only applying when auto-paired? The BatchSpanProcessor reads from the environment variables directly
https://github.com/open-telemetry/opentelemetry-js/blob/31eb60dc99dc066cf2085864f2727eb29ee76e91/packages/opentelemetry-sdk-trace-base/src/export/BatchSpanProcessorBase.ts#L55-L58
so the environment variables are applied globally. I'm guessing this is related to the yaml config file conversation and the related concern around precedence
That's correct, the spec does not mention anything about auto-pairing. However, we currently don't apply any env var config in the @opentelemetry/sdk-metrics package as we've realized that mixing in env var config with SDK code quickly tends to grow to unmaintainable,very hard-to-debug, and very hard-to-test levels. SDK code for the @opentelemetry/sdk-metrics package is intended to work both in Node.js and the Browser - by adding environment config code that's dead for Browser users, we further increase bundle size which unfortunately is already at unsustainable levels.
In future iterations of the SDK (metrics, traces and logs), we will pull all environment config code into separate files, so that pure SDK packages are free of environment config code. A further challenge will be the introduction of file-config support which will be easier to address when enviornment config is seperate from the actual SDKs