Skip to content

Commit 7ff2465

Browse files
[componentattribute] Use otelzap.WithAttributes, remove LoggerProviderWithAttributes (#13108)
#### Description Now that `otelzap` has been bumped up to 0.11.0 (#13103), this PR follows up on a TODO comment to use open-telemetry/opentelemetry-go-contrib#6962 to set instrumentation scope attributes on the Logger created by otelzap, instead of a workaround (`LoggerProviderWithAttributes`). This is an internal change, and the new code should be functionally equivalent, so I don't think this needs a changelog. #### Testing I believe this is already covered by existing tests.
1 parent 4a37179 commit 7ff2465

File tree

2 files changed

+2
-41
lines changed

2 files changed

+2
-41
lines changed

internal/telemetry/componentattribute/logger_provider.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

internal/telemetry/componentattribute/logger_zap.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ var _ coreWithAttributes = (*otelTeeCoreWithAttributes)(nil)
8686
//
8787
// This is used when service::telemetry::logs::processors is configured.
8888
func NewOTelTeeCoreWithAttributes(consoleCore zapcore.Core, lp log.LoggerProvider, scopeName string, level zapcore.Level, attrs attribute.Set, wrapper func(zapcore.Core) zapcore.Core) zapcore.Core {
89-
// TODO: Use `otelzap.WithAttributes` and remove `LoggerProviderWithAttributes`
90-
// once we've upgraded to otelzap v0.11.0.
91-
lpwa := LoggerProviderWithAttributes(lp, attrs)
9289
otelCore, err := zapcore.NewIncreaseLevelCore(otelzap.NewCore(
9390
scopeName,
94-
otelzap.WithLoggerProvider(lpwa),
91+
otelzap.WithLoggerProvider(lp),
92+
otelzap.WithAttributes(attrs.ToSlice()...),
9593
), zap.NewAtomicLevelAt(level))
9694
if err != nil {
9795
panic(err)

0 commit comments

Comments
 (0)