Skip to content

feat(config): wire top-level log_level field in declarative configuration#5351

Open
ocelotl wants to merge 3 commits into
open-telemetry:mainfrom
ocelotl:diego/config-log-level-wiring
Open

feat(config): wire top-level log_level field in declarative configuration#5351
ocelotl wants to merge 3 commits into
open-telemetry:mainfrom
ocelotl:diego/config-log-level-wiring

Conversation

@ocelotl

@ocelotl ocelotl commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

The declarative configuration schema has a top-level log_level field that controls the SDK's internal diagnostic logging verbosity. It was parsed and validated by the schema loader but never read by configure_sdk — so setting it in a config file had no observable effect.

This PR wires log_level into configure_sdk: when the field is present, it maps the OTel SeverityNumber value to a Python logging level and sets it on the opentelemetry root logger. All numbered severity variants (e.g. debug2, warn3) collapse to the same Python tier.

Mapping:

OTel severity Python level
trace, trace2–4 DEBUG
debug, debug2–4 DEBUG
info, info2–4 INFO
warn, warn2–4 WARNING
error, error2–4 ERROR
fatal, fatal2–4 CRITICAL

When log_level is absent the logger is untouched, preserving existing behaviour.

Fixes the gap noted in #5347 (log_level ❌ — No tracker yet).

Type of change

  • Bug fix / gap closure (non-breaking change that makes existing behaviour match the spec)

How Has This Been Tested?

Three new unit tests in test_sdk.py:

  • test_sets_opentelemetry_logger_level — verifies a specific severity sets the expected level
  • test_absent_log_level_leaves_logger_unchanged — verifies no mutation when field is absent
  • test_severity_number_variants_map_correctly — exhaustive subTest over all tiers (trace, debug, info, warn, error, fatal + their *4 variants)

Does This PR Require a Contrib Repo Change?

  • Yes.
  • No.

Checklist

  • Followed the style guidelines of this project
  • Changelogs have been updated (will add once PR number is known)
  • Unit tests have been added
  • Documentation has been updated (spec-conformance.md row will change from ❌ to ✅)

🤖 Generated with Claude Code

@ocelotl ocelotl requested a review from a team as a code owner June 25, 2026 01:08
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 25, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

ocelotl added a commit to ocelotl/opentelemetry-python that referenced this pull request Jun 25, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ocelotl ocelotl marked this pull request as draft June 25, 2026 01:24

@MikeGoldsmith MikeGoldsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks pretty good. I've left one suggestion regarding default level.

Comment thread opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_sdk.py Outdated
ocelotl and others added 3 commits June 26, 2026 15:35
Map the top-level `log_level` field from declarative configuration to
the `opentelemetry` root logger level so SDK internal diagnostics
respect the configured severity.
Co-authored-by: Mike Goldsmith <goldsmith.mike@gmail.com>
@ocelotl ocelotl force-pushed the diego/config-log-level-wiring branch from 97cc820 to e64f998 Compare June 26, 2026 21:36
@ocelotl ocelotl marked this pull request as ready for review June 26, 2026 21:54
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.

2 participants