Repository navigation
[OpenTelemetry] Use config binder source generator - #8100
Conversation
Use the configuration binding source generator for logging settings when targeting .NET. Fixes open-telemetry#4725.
Pull request dashboard statusMerged · refreshed 2026-11-10 11:33 UTC Status above doesn't look right?
|
There was a problem hiding this comment.
🟡 Changes recommended
The changelog still contains #TODO and /pull/TODO placeholders that must be replaced with PR number 8100 to provide the required usable pull-request reference.
1 open issue
What changed in this PR
This PR addresses #4725 by moving SDK logging-option binding to the configuration binding source generator on .NET, improving trimming and Native AOT compatibility.
Changes:
- Adds a dedicated options configurator while preserving configuration-change notifications.
- Replaces the reflection-based trimming test with tests for option binding, single registration, and change tokens.
- Documents the change in the SDK changelog.
[!NOTE]
This review was generated with GitHub Copilot.
| File | Description |
|---|---|
| test/OpenTelemetry.Tests/Logs/OpenTelemetryLoggingExtensionsTests.cs | Tests configuration binding, internal defaults, registration, and change notifications. |
| src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggingExtensions.cs | Registers the new configurator and removes obsolete warning suppressions. |
| src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggerOptionsConfigureOptions.cs | Adds the binding call used by the source generator. |
| src/OpenTelemetry/CHANGELOG.md | Records the trimming and Native AOT improvement. |
Review effort: Balanced
- Fix redundant using. - Update CHANGELOG.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8100 +/- ##
==========================================
- Coverage 93.09% 93.06% -0.04%
==========================================
Files 397 399 +2
Lines 23335 23759 +424
Branches 4359 4490 +131
==========================================
+ Hits 21724 22111 +387
- Misses 1103 1120 +17
- Partials 508 528 +20
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Kielek
left a comment
There was a problem hiding this comment.
Changes in general LGTM.
Codex detected one difference:
[P2] Empty boolean settings behave differently on .NET 11. With Logging:OpenTelemetry:IncludeScopes = "", the old binder throws InvalidOperationException; the generated binder skips the value, leaving IncludeScopes at its default. I reproduced this with the new binding call. Preserve the previous validation, or explicitly test and document this change. Comparison output.
|
- Document binding behaviour change in CHANGELOG. - Inline binding code registrations. - Remove redundant "Note:" comments. - Update tests.

Fixes #4725
Changes
Use the configuration binding source generator for logging settings when targeting .NET.
Merge requirement checklist
CHANGELOG.mdfile(s) updated for non-trivial changesChanges in public API reviewed (if applicable)Footnotes
Yes, I can answer maintainer questions about the content of this PR without using AI. ↩