-
Notifications
You must be signed in to change notification settings - Fork 987
Description
Is your feature request related to a problem? Please describe.
To consolidate configuration for all our services we would like to configure the node sdk fully through the use of env vars like we do for the java/ruby sdk
see the related specs here:
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#otlp-exporter
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md
Describe the solution you'd like
One example would be the following
// import buildTraceExporterFromEnv from somewhere
// configure the exporters you want to allow somewhere?
const sdk = new opentelemetry.NodeSDK({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'myservice',
}),
traceExporter: buildTraceExporterFromEnv(),
instrumentations: [getNodeAutoInstrumentations()]
})that buildTraceExporterFromEnv could also be the default for traceExporter
In the code we register a number of exporters we want to support
OTEL_TRACES_EXPORTER=otlp
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://..../v1/traces"
Describe alternatives you've considered
We currently have to do handle the OTEL_TRACES_EXPORTER / OTEL_EXPORTER_OTLP_PROTOCOL to exporter selection manually.
Additional context
Current situation:
-
if you don't set a
traceExporteron the NodeSDK tracing will be disabled -
When using
BasicTracerProviderthe exporter is configured through OTEL_TRACES_EXPORTER as in the specopentelemetry-js/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts
Lines 251 to 261 in 7870e95
protected _buildExporterFromEnv(): SpanExporter | undefined { const exporterName = getEnv().OTEL_TRACES_EXPORTER; if (exporterName === 'none') return; const exporter = this._getSpanExporter(exporterName); if (!exporter) { diag.error( `Exporter "${exporterName}" requested through environment variable is unavailable.` ); } return exporter; }