logs: add Enabled support to Logger API, SDK, and LogRecordProcessor#5380
Open
ocelotl wants to merge 2 commits into
Open
logs: add Enabled support to Logger API, SDK, and LogRecordProcessor#5380ocelotl wants to merge 2 commits into
ocelotl wants to merge 2 commits into
Conversation
Implements the Enabled chain from the OpenTelemetry Logs specification: - API Logger.enabled(context, severity_number, event_name) -> bool: default True; NoOpLogger returns False; ProxyLogger delegates. - SDK LogRecordProcessor.enabled(...) -> bool: non-abstract default True so existing processors opt-in by overriding. - SDK SynchronousMultiLogRecordProcessor/ConcurrentMultiLogRecordProcessor: enabled() returns False when no processors are registered, False when all processors return False, otherwise True. - SDK Logger.enabled(): checks LoggerConfig.is_enabled first, then delegates to the multi-processor with the instrumentation scope. Closes open-telemetry#5360
…g fragment Add pylint disable=no-self-use annotations to the enabled() default implementations in the Logger API and LogRecordProcessor SDK base classes, matching the existing pattern used for force_flush(). Also add the missing .changelog/5380.added fragment required by the changelog CI check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
Enabledchain from the OpenTelemetry Logs specification, closes #5360.Logger.enabled(context, severity_number, event_name) -> bool: non-abstract default returningTrue;NoOpLoggerreturnsFalse;ProxyLoggerdelegates to the real logger.LogRecordProcessor.enabled(context, instrumentation_scope, severity_number, event_name) -> bool: non-abstract default returningTrue— processors opt into filtering by overriding this method.SynchronousMultiLogRecordProcessor/ConcurrentMultiLogRecordProcessor:enabled()returnsFalsewhen no processors are registered,Falsewhen all processors returnFalse,Trueotherwise.Logger.enabled(): checksLoggerConfig.is_enabledfirst, then delegates to the multi-processor with the logger's instrumentation scope.Test plan
False, processor present →True, disabled logger config →False, args forwarded to processor, all processors disabled →False, one processor enabled →TrueNoOpLogger.enabled()→False,ProxyLogger.enabled()delegates to real logger,ProxyLogger.enabled()falls back to no-op