wip: configure SDK internal logger from log_level#8413
Draft
CtrlSpice wants to merge 3 commits intoopen-telemetry:mainfrom
Draft
wip: configure SDK internal logger from log_level#8413CtrlSpice wants to merge 3 commits intoopen-telemetry:mainfrom
CtrlSpice wants to merge 3 commits intoopen-telemetry:mainfrom
Conversation
codeboten
reviewed
Jan 16, 2026
Contributor
codeboten
left a comment
There was a problem hiding this comment.
Thanks @CtrlSpice! Added some comments
otelconf/config.go
Outdated
| case "error", "fatal": | ||
| stdr.SetVerbosity(0) | ||
| default: | ||
| return fmt.Errorf("invalid log_level %q", *logLevel) |
Contributor
There was a problem hiding this comment.
This can return a newErrInvalid here
| return noopSDK, nil | ||
| } | ||
|
|
||
| if err := setInternalLogger(o.opentelemetryConfig.LogLevel); err != nil { |
Contributor
There was a problem hiding this comment.
would love some thoughts from @open-telemetry/go-approvers on whether this should set a logger here or if it should provide a method to return a configured logger that can be set by the caller of this function.
Since the rest of this code is not modifying the global context, i suspect the latter, even though setting the logger here is nice
Author
There was a problem hiding this comment.
Happy to refactor to return a configured logger if that's more consistent!
CHANGELOG.md
Outdated
Comment on lines
13
to
14
| - Add support for `log_level` configuration to set the SDK's internal logger verbosity in `go.opentelemetry.io/contrib/otelconf`. (#8210) | ||
| - `WithMetricAttributesFn` option in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` to define dynamic attributes on auto-instrumented metrics. (#8191) |
Contributor
There was a problem hiding this comment.
Suggested change
| - Add support for `log_level` configuration to set the SDK's internal logger verbosity in `go.opentelemetry.io/contrib/otelconf`. (#8210) | |
| - `WithMetricAttributesFn` option in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` to define dynamic attributes on auto-instrumented metrics. (#8191) | |
| - `WithMetricAttributesFn` option in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` to define dynamic attributes on auto-instrumented metrics. (#8191) | |
| - Add support for `log_level` configuration to set the SDK's internal logger verbosity in `go.opentelemetry.io/contrib/otelconf`. (#8210) |
81fd4c9 to
40cc037
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements support for the
log_levelconfiguration field to configure the SDK's internal logger viaotel.SetLogger().The log level maps to
stdrverbosity as follows:log_leveltrace,debuginfowarnerror,fatalNumeric suffixes (e.g.,
debug2,trace4) are accepted and mapped to their base level, since Go'slogrdoesn't have that granularity.Closes #8210
Changes
setInternalLogger()function inconfig.gosetInternalLogger()log_levelinTestNewSDKTesting
All existing tests pass. New tests cover:
info,debug,debug2,warn,error,trace,trace4,fatalnil(unset) is handled gracefully