Skip to content

oss_22_logger_enabled - #26

Open
ocelotl wants to merge 2 commits into
mainfrom
oss_22_logger_enabled
Open

oss_22_logger_enabled#26
ocelotl wants to merge 2 commits into
mainfrom
oss_22_logger_enabled

Conversation

@ocelotl

@ocelotl ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Closes #22

Add public Logger.enabled(context, severity_number, event_name) to logs API and SDK, delegating to a processor-level enabled hook (Linear OSS-22, finding L3). Validation: api+sdk logs suites 129 passed, scope api+sdk+changelog.

Linear issue: https://linear.app/dash0/issue/OSS-22/l3-logs-apisdk-missing-the-loggerenabled-operation

@ocelotl ocelotl mentioned this pull request Jul 22, 2026
@ocelotl

ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

🔒 Internal (dash0) — not for upstream.

@ocelotl

ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

📣 Public-facing draft — to be used for the upstream PR in open-telemetry/opentelemetry-python. No internal references; copy verbatim.

Title: Add public Logger.enabled operation to the Logs API and SDK

What

  • Adds a public enabled(context=None, severity_number=None, event_name=None) -> bool to the API Logger. The base/no-op implementation returns False (no records are ever emitted), matching the Go no-op logger.
  • ProxyLogger.enabled forwards to the resolved real (or no-op) logger.
  • Implements enabled on the SDK Logger: returns True only when the logger is not disabled by its configuration and at least one registered processor is enabled for the given arguments.
  • Adds an optional enabled(...) hook to LogRecordProcessor (default True) and to SynchronousMultiLogRecordProcessor / ConcurrentMultiLogRecordProcessor (true if any child is enabled; false when none registered).

Why

The Logs API spec defines a Logger "Enabled" operation taking Context, Severity Number, and Event Name, as an optional performance optimization to avoid building LogRecords that would be dropped. Python only had a private, argument-less _is_enabled() on the SDK Logger and nothing on the API. Go (sdk/log/logger.go Enabled(ctx, EnabledParameters)) and Java (Logger.isEnabled) already provide this.

Spec

Logs API, "Logger's Enabled Operation".

Tests

New API tests: no-op enabled() returns False and accepts all parameters; ProxyLogger delegates/falls back to no-op. New SDK tests: False with no processors, True with an enabled processor, False when a processor reports disabled, True when any processor is enabled, False when the config disables it, parameters forwarded, and multi-processor aggregation. Existing API+SDK logs suites pass (129).

Backward compatibility

The new processor hook is non-abstract with a True default, so existing custom processors need no changes.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Aug 6, 2026
ocelotl added 2 commits August 7, 2026 15:53
Implements the Logs API "Enabled" operation. Adds a public
enabled(context, severity_number, event_name) -> bool method to the API
Logger (default False, matching the no-op logger) and to the SDK Logger,
which delegates to processor-level enabled hooks and honors the logger
configuration. Adds an optional enabled hook to LogRecordProcessor and
the multi-processors so processors can report disabled cheaply.
@ocelotl
ocelotl force-pushed the oss_22_logger_enabled branch from fafd546 to a215c15 Compare August 7, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oss_22_logger_enabled

1 participant