Passing logRecordProcessors
as an empty array should not initialize LoggerProvider
#5300
Labels
logRecordProcessors
as an empty array should not initialize LoggerProvider
#5300
Is your feature request related to a problem? Please describe
If
OTEL_EXPORTER_OTLP_LOGS_PROTOCOL
environment variable is set tonone
, the NodeSDK will not initialize a global logger provider at all.There's no easy way to have the same behavior if we use
logRecordsProcessor
option in the constructor to disable logging. Passing nullish loads from environment variables, which will default to usingotlp
. Passing an empty array, results in an instance ofLoggerProvider
to be set as the global provider, which might have some overhead.I would like to have a way to signal the SDK programmatically (e.g.: via
logRecordsProcessor = []
in the constructor) to disable logs similar to settingOTEL_EXPORTER_OTLP_LOGS_PROTOCOL: "none"
env variable.Indirectly related: it seems strange that the behavior of
OTEL_EXPORTER_OTLP_LOGS_PROTOCOL: "none"
is to not initialize any logger provider. Shouldn't we initialize aNoopLoggerProvider
similar to how we are initializing aNoopTracerProvider
?Describe the solution you'd like to see
Passing an empty array in the
logRecordsProcessor
option should initialize aNoopLoggerProvider
.Describe alternatives you've considered
Call
logs.setGlobalLoggerProvider(new NoopLoggerProvider())
before callingstart
. It does the job, since once the global provider is set, it's not overwritten.Additional context
N/A
The text was updated successfully, but these errors were encountered: