Skip to content

[Declarative Config] Phase 24a: Apply self-diagnostics log level - #8101

Open
stevejgordon wants to merge 1 commit into
open-telemetry:mainfrom
stevejgordon:declarative-config-phase-24a
Open

stevejgordon wants to merge 1 commit into
open-telemetry:mainfrom
stevejgordon:declarative-config-phase-24a

Conversation

@stevejgordon

Copy link
Copy Markdown
Contributor

Contibutes to #7658

Changes

Apply the root log_level to SDK self-diagnostics, validating all 24 lowercase schema values and mapping them to .NET logging levels. Preserve code-based overrides and the document threshold across configuration reloads. Setting the level does not enable diagnostic output.

Merge requirement checklist

  • [CONTRIBUTING][contributing] guidelines followed (license requirements, successful build/tests, etc.)
  • Tests added/updated
  • CHANGELOG.md file(s) updated for non-trivial changes
  • Changes in public API reviewed (if applicable)
  • [AI usage][gen-ai] disclosure:
    • No AI used
    • AI-assisted
    • Bulk AI-generated

Note

The implementation and this PR description were prepared with GitHub CoPilot (GPT-Sol 6.1) and Claude Code (Opus 5.5)

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-11-10 12:43 UTC

Respond to 4 review items (e.g. link a commit, explain why not, ask a follow-up):

  • Inline threads: 1, 2, 3, 4
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@stevejgordon
stevejgordon force-pushed the declarative-config-phase-24a branch from 90e2795 to 1319517 Compare November 9, 2026 18:38
@github-actions github-actions Bot added the pkg:OpenTelemetry.Configuration.Declarative Issues related to OpenTelemetry.Configuration.Declarative NuGet package label Nov 9, 2026
@stevejgordon
stevejgordon force-pushed the declarative-config-phase-24a branch from 1319517 to 040dbe4 Compare November 9, 2026 18:41
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.08%. Comparing base (1e88560) to head (5466bb0).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8101      +/-   ##
==========================================
- Coverage   93.09%   93.08%   -0.01%     
==========================================
  Files         397      401       +4     
  Lines       23335    23809     +474     
  Branches     4359     4500     +141     
==========================================
+ Hits        21724    22163     +439     
- Misses       1103     1119      +16     
- Partials      508      527      +19     
Flag Coverage Δ
unittests-Project-Experimental 93.06% <100.00%> (-0.15%) ⬇️
unittests-Project-Stable 93.17% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...emetryBuilderDeclarativeConfigurationExtensions.cs 98.74% <100.00%> (+0.03%) ⬆️
...al/Diagnostics/DocumentLogLevelConfigureOptions.cs 100.00% <100.00%> (ø)
...arative/Internal/Model/DeclarativeConfiguration.cs 100.00% <ø> (ø)
...arative/Internal/Model/SeverityNumberExtensions.cs 100.00% <100.00%> (ø)
...n.Declarative/Internal/Pipeline/SupportManifest.cs 100.00% <100.00%> (ø)
...ve/Internal/Yaml/DeclarativeConfigurationParser.cs 99.35% <100.00%> (+0.05%) ⬆️
....Declarative/Internal/Yaml/SeverityNumberParser.cs 100.00% <100.00%> (ø)

... and 8 files with indirect coverage changes

@stevejgordon
stevejgordon force-pushed the declarative-config-phase-24a branch from 040dbe4 to 2cb24f4 Compare November 10, 2026 07:50
Assisted-by: OpenAI Codex (GPT-Sol 6.1)
Assisted-by: Claude Code (Opus 5.5)
@stevejgordon
stevejgordon force-pushed the declarative-config-phase-24a branch from 2cb24f4 to 5466bb0 Compare November 10, 2026 08:21
@stevejgordon
stevejgordon marked this pull request as ready for review November 10, 2026 08:49
@stevejgordon
stevejgordon requested a review from a team as a code owner November 10, 2026 08:49
Comment on lines +22 to +30
internal static LogLevel ToLogLevel(this SeverityNumber severity) => severity switch
{
<= SeverityNumber.Trace4 => LogLevel.Trace,
<= SeverityNumber.Debug4 => LogLevel.Debug,
<= SeverityNumber.Info4 => LogLevel.Information,
<= SeverityNumber.Warn4 => LogLevel.Warning,
<= SeverityNumber.Error4 => LogLevel.Error,
_ => LogLevel.Critical,
};

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.

Should we explicitly handle default(SeverityNumber) somehow, as that's not a defined value in the enum?

Comment on lines +74 to +75
YamlScalarKind.String => ModelProperty<SeverityNumber>.Create(
SeverityNumberParser.Parse(YamlKeys.LogLevel, resolved.Value, valueNode.Start)),

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.

Slightly more readable IMHO.

Suggested change
YamlScalarKind.String => ModelProperty<SeverityNumber>.Create(
SeverityNumberParser.Parse(YamlKeys.LogLevel, resolved.Value, valueNode.Start)),
YamlScalarKind.String => ModelProperty<SeverityNumber>.Create(SeverityNumberParser.Parse(YamlKeys.LogLevel, resolved.Value, valueNode.Start)),

new($"'{key}' {Describe(position)} must be a string, but is a {actual} value. Allowed values are: {AllowedValues}.");

private static string Describe(Mark position) =>
$"at line {position.Line.ToString(CultureInfo.InvariantCulture)}, column {position.Column.ToString(CultureInfo.InvariantCulture)}";

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.

Suggested change
$"at line {position.Line.ToString(CultureInfo.InvariantCulture)}, column {position.Column.ToString(CultureInfo.InvariantCulture)}";
FormattableString.Invariant($"at line {position.Line}, column {position.Column}");

Comment on lines +70 to +81
var severities = new Dictionary<string, SeverityNumber>(24, StringComparer.Ordinal);
foreach (var severity in Enum.GetValues<SeverityNumber>())
{
severities[severity.ToString().ToLowerInvariant()] = severity;
}

return severities.ToFrozenDictionary(StringComparer.Ordinal);
}
#else
private static Dictionary<string, SeverityNumber> BuildSeverities()
{
var severities = new Dictionary<string, SeverityNumber>(24, StringComparer.Ordinal);

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.

Make the 24 a constant and cross reference the need to update it in a comment in the enum if more ever get added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Configuration.Declarative Issues related to OpenTelemetry.Configuration.Declarative NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants