-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] log: LoggerProvider.Logger to accept LoggerConfig instead of options #5367
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5367 +/- ##
=======================================
- Coverage 84.6% 84.5% -0.1%
=======================================
Files 268 267 -1
Lines 17704 17673 -31
=======================================
- Hits 14982 14951 -31
Misses 2410 2410
Partials 312 312
|
Logger(cfg LoggerConfig) Logger | ||
} | ||
|
||
// LoggerConfig contains options for a [Logger]. | ||
type LoggerConfig struct { | ||
// Ensure forward compatibility by explicitly making this not comparable. | ||
noCmp [0]func() //nolint: unused // This is indeed used. | ||
|
||
Name string | ||
Version string | ||
SchemaURL string | ||
Attributes attribute.Set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very similar alternative would be to have the name as a separate parameter to indicate that it is required:
Logger(cfg LoggerConfig) Logger | |
} | |
// LoggerConfig contains options for a [Logger]. | |
type LoggerConfig struct { | |
// Ensure forward compatibility by explicitly making this not comparable. | |
noCmp [0]func() //nolint: unused // This is indeed used. | |
Name string | |
Version string | |
SchemaURL string | |
Attributes attribute.Set | |
Logger(name string, cfg LoggerConfig) Logger | |
} | |
// LoggerConfig contains options for a [Logger]. | |
type LoggerConfig struct { | |
// Ensure forward compatibility by explicitly making this not comparable. | |
noCmp [0]func() //nolint: unused // This is indeed used. | |
Version string | |
SchemaURL string | |
Attributes attribute.Set |
Closing per open-telemetry/opentelemetry-go-contrib#5586 (comment) . We may resurrect this if bridge implementation would give a feedback that it would be better to change the Bridge API. CC @MrAlias |
I think that the cache would need to be synchronized to avoid race conditions and it would decrease the performance. CC @MrAlias |
Reopening and making as draft per #5367 (comment). Adding to blocked in the project to indicated that it is blocked until there is a use case that would support this change (e.g. ease of use in bridge implementations, better performance of bridge implementations). |
I plan to make some PoC bridge implementation for zap or/and logr just to validate the "logger" optimizations to make sure that this proposal is not needed. EDIT: Upon quick look I think that a PoC for zap would be enough as it would be the most problematic one because the "logger name" is a on "log record level" in zap. See: https://pkg.go.dev/go.uber.org/zap/zapcore#Entry EDIT2: Most probably using a |
Showcase open-telemetry/opentelemetry-go-contrib#5586 (comment)
Basically the thesis from https://github.com/open-telemetry/opentelemetry-go/blob/main/log/DESIGN.md#passing-struct-as-parameter-to-loggerproviderlogger:
may not be true (as we may want to acquire a logger before emitting each log record).