open-telemetry / open-telemetry/opentelemetry-python

Public API for setting logger/tracer configuration programmatically

Open
#5,524 3 comments 0 reactions 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

Provide a public API to set logger (and, for consistency, tracer) configuration programmatically at runtime, so users can enable/disable a logger or adjust its config without relying on the private _-prefixed API.

Background

PR #5380 wires Logger.enabled() to consult LoggerConfig.is_enabled. The configuration itself is already settable programmatically today, but only through private API:

  • _LoggerConfig(is_enabled=...)
  • LoggerProvider._set_logger_configurator(logger_configurator=...) / the _logger_configurator constructor argument

This came up in review on #5380 (https://github.com/open-telemetry/opentelemetry-python/pull/5380#discussion_r3715217160), where the question was raised that it should eventually be possible to set this via a public API.

Why this is a separate change

The tracer side is the template for this code and is also still private (_TracerConfig, TracerProvider._set_tracer_configurator). Promoting logger config to a public API in isolation would diverge the two signals. This should be a deliberate, consistent cross-signal decision (traces and logs, and any future signal), so it does not belong inside the enabled() PR.

Proposed scope

  • Decide on the public surface for setting config on a provider (configurator callable vs. direct config object, naming).
  • Apply it consistently to both TracerProvider and LoggerProvider.
  • Keep the existing private entry points working (or alias them) during the transition.

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

Start by reviewing the private _LoggerConfig, LoggerProvider._set_logger_configurator, _logger_configurator, _TracerConfig, and TracerProvider._set_tracer_configurator entry points, along with the discussion in PR #5380. Define a consistent public configuration surface for both providers, preserve the existing private entry points during transition, and verify that the resulting API covers logger and tracer configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.