opentelemetry-js
opentelemetry-js copied to clipboard
[sdk-node] automatically configure logs exporter based on enviornment variables
Currently, we don't auto-configure a LogRecordProcessor/exporter combination when using the @opentelemetry/sdk-node package.
Goal of this issue is to implement exporter selection for metrics based on this specification:
- https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#exporter-selection
For this issue to be considered done we need to implement the following behavior:
If no log record proccessor is configured by the user:
- [ ] use
OTEL_LOGS_EXPORTERenvironment variable to determine an exporter and add it to theLoggerProviderthat's created byNodeSDK- pair it up with a
BatchLogRecordProcessor - see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#exporter-selection
- pair it up with a
- [ ] use the
OTEL_EXPORTER_OTLP_LOGS_PROTOCOLto determine the OTLP exporter to use (http/json, http/protobuf, grpc)- see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specify-protocol
- [ ] use the
OTEL_EXPORTER_OTLP_PROTOCOLenv var as a fallback to the above to determine the OTLP exporter to use (http/json, http/protobuf, grpc) - [ ] fallback to using http/protobuf if none of the two protocol env vars are set
Can assign to me.
It's yours :slightly_smiling_face:
Hi guys, sorry for bothering you, but is it true that currently logs auto instrumentation is not supported for nodejs like we have it for python?
If yes, is PR #4740 implement this?
@evheniyt Recent versions of instrumentation packages for Bunyan, Winston, and Pino do support auto-instrumenting those libraries to support log sending via the Logs Bridge API (https://opentelemetry.io/docs/specs/otel/logs/bridge-api/). However, for that log sending to work, a global LoggerProvider needs to be setup to receive those log records from the instrumented libraries. This issue is about getting the OTel SDK for Node.js (a.k.a. NodeSDK) to automatically register a global LoggerProvider is a way similar to how it registers a default global TracerProvider for tracing.
to automatically register a global LoggerProvider
Currently, when using the NodeSDK, it will only register a global LoggerProvider if you pass in the logRecordProcessor config option. Something like:
const sdk = new NodeSDK({
// ... other options
logRecordProcessor: new BatchLogRecordProcessor(new OTLPLogExporter())
});
sdk.start();
(Aside: I notice that the logRecordProcessor option isn't even documented at https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-sdk-node/README.md#configuration)