open-telemetry / open-telemetry/opentelemetry-python

Logs Enabled: implement Development-status conditions (minimum_severity, trace_based)

Open
#5,525 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

What

Implement the remaining, Development-status conditions of the Logs Enabled spec in the SDK: severity-based filtering (minimum_severity) and trace-based filtering (trace_based).

Background

PR #5380 adds Logger.enabled() and implements the stable conditions of the spec's Enabled section:

  • there are no registered LogRecordProcessors
  • LoggerConfig.enabled is false (handled in Logger.enabled())
  • all registered LogRecordProcessors implement Enabled and each returns false

The spec lists two further conditions under which Enabled MUST return false, both currently marked [Development]:

  • the provided severity is specified (not 0) and is less than the configured minimum_severity
  • trace_based is true and the current context is associated with an unsampled trace

These were intentionally deferred out of #5380 (see https://github.com/open-telemetry/opentelemetry-python/pull/5380#discussion_r3715247579 and the issue discussion at https://github.com/open-telemetry/opentelemetry-python/issues/5360#issuecomment-5183215458).

Why deferred

  • Both conditions are still Development status in the spec and subject to change.
  • _LoggerConfig currently only has is_enabled; these conditions require adding minimum_severity and trace_based fields to the config model first. The tracer analog _TracerConfig also only has is_enabled, so the config model should grow consistently across signals (related: #5524).

Proposed scope

  • Add minimum_severity and trace_based fields to _LoggerConfig.
  • Have Logger.enabled() return false when the provided severity is below minimum_severity, and when trace_based is set and the current context is an unsampled trace.
  • Track the spec closely, since these conditions are Development status.

cc @aabmass @herin049

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review PR #5380 and the Logs SDK Enabled specification, then trace Logger.enabled(), _LoggerConfig, and the related _TracerConfig model. Implement the minimum_severity and trace_based conditions while keeping the configuration models consistent. Done means both Development-status conditions are reflected in enabled decisions for unsampled traces and below-threshold severities.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.