Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing logRecordProcessors as an empty array should not initialize LoggerProvider #5300

Open
satazor opened this issue Dec 26, 2024 · 0 comments

Comments

@satazor
Copy link
Contributor

satazor commented Dec 26, 2024

Is your feature request related to a problem? Please describe

If OTEL_EXPORTER_OTLP_LOGS_PROTOCOL environment variable is set to none, 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 using otlp. Passing an empty array, results in an instance of LoggerProvider 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 setting OTEL_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 a NoopLoggerProvider similar to how we are initializing a NoopTracerProvider?

Describe the solution you'd like to see

Passing an empty array in the logRecordsProcessor option should initialize a NoopLoggerProvider.

Describe alternatives you've considered

Call logs.setGlobalLoggerProvider(new NoopLoggerProvider()) before calling start. It does the job, since once the global provider is set, it's not overwritten.

Additional context

N/A

@satazor satazor changed the title Passing logRecordProcessors as an empty array should not initialize LoggerProvider or initialize NoopLoggerProvider Passing logRecordProcessors as an empty array should not initialize LoggerProvider Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant