Skip to content

Add enabled checks for logs API, SDK, and processors - #5500

Open
saisharan0103 wants to merge 1 commit into
open-telemetry:mainfrom
saisharan0103:mergepath/issue-5360-logging-stability-review-major-no-enable
Open

Add enabled checks for logs API, SDK, and processors#5500
saisharan0103 wants to merge 1 commit into
open-telemetry:mainfrom
saisharan0103:mergepath/issue-5360-logging-stability-review-major-no-enable

Conversation

@saisharan0103

Copy link
Copy Markdown

Issue #5360 reported that the logs API only exposes Logger.emit, leaving instrumentation without a public enabled predicate to avoid constructing expensive LogRecord objects. The SDK logger also only had a private _is_enabled() configurator check and did not consult registered LogRecordProcessor instances or processor interest for the current context, instrumentation scope, severity number, and event name.

This adds a public enabled(context=None, severity_number=None, event_name=None) method to the API logger surface. NoOpLogger returns false, and ProxyLogger forwards the check to the real logger.

The SDK now exposes an optional default LogRecordProcessor.enabled(context, instrumentation_scope, severity_number, event_name) hook and implements the multi-processor predicate so it returns false with no processors, returns false only when every registered processor returns false, and returns true when any processor returns true.

Logger.enabled now combines the existing logger configurator gate with the multi-processor predicate. emit calls enabled with the record or parameter context, severity, and event before creating or forwarding the writable record.

Updated files:

  • opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py
  • opentelemetry-api/tests/logs/test_proxy.py
  • opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
  • opentelemetry-sdk/tests/logs/test_logs.py
  • opentelemetry-sdk/tests/logs/test_multi_log_processor.py

ruff check opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py opentelemetry-api/tests/logs/test_proxy.py opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py opentelemetry-sdk/tests/logs/test_logs.py opentelemetry-sdk/tests/logs/test_multi_log_processor.py reports no new findings on the changed files.
Ran pytest -x locally with no new failures.

…No `Enabled` support across API, SDK, and processors

Closes open-telemetry#5360
@saisharan0103
saisharan0103 requested a review from a team as a code owner August 2, 2026 06:36
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Missing ID

  • ❌ The email address for the commit (5c078d3) is not linked to the GitHub account, preventing the EasyCLA check. Consult this Help Article and GitHub Help to resolve. (To view the commit's email address, add .patch at the end of this PR page's URL.) For further assistance with EasyCLA, please visit our EasyCLA portal and chat with our support bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant