open-telemetry / open-telemetry/opentelemetry-python
Logs Enabled: implement Development-status conditions (minimum_severity, trace_based)
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.enabledisfalse(handled inLogger.enabled())- all registered
LogRecordProcessorsimplementEnabledand each returnsfalse
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 configuredminimum_severity trace_basedistrueand 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.
_LoggerConfigcurrently only hasis_enabled; these conditions require addingminimum_severityandtrace_basedfields to the config model first. The tracer analog_TracerConfigalso only hasis_enabled, so the config model should grow consistently across signals (related: #5524).
Proposed scope
- Add
minimum_severityandtrace_basedfields to_LoggerConfig. - Have
Logger.enabled()returnfalsewhen the provided severity is belowminimum_severity, and whentrace_basedis set and the current context is an unsampled trace. - Track the spec closely, since these conditions are Development status.
cc @aabmass @herin049
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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