Skip to content

Commit

Permalink
update logger to use NewTee to preserve existing logger config
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten committed Oct 21, 2024
1 parent cbeca87 commit 7753636
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions service/telemetry/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,25 @@ func newLogger(ctx context.Context, cfg LogsConfig, options []zap.Option) (*zap.
LoggerProvider: &config.LoggerProvider{
Processors: cfg.Processors,
},
// TODO: add resource
// Resource: &config.Resource{},
},
),
)

if err != nil {
return nil, err
}

Check warning on line 56 in service/telemetry/logger.go

View check run for this annotation

Codecov / codecov/patch

service/telemetry/logger.go#L41-L56

Added lines #L41 - L56 were not covered by tests
logger = logger.WithOptions(zap.WrapCore(func(_ zapcore.Core) zapcore.Core {
return otelzap.NewCore("go.opentelemetry.io/collector/service/telemetry", otelzap.WithLoggerProvider(sdk.LoggerProvider()))

logger = logger.WithOptions(zap.WrapCore(func(c zapcore.Core) zapcore.Core {
return zapcore.NewTee(
logger.Core(),
otelzap.NewCore("go.opentelemetry.io/collector/service/telemetry",
otelzap.WithLoggerProvider(sdk.LoggerProvider()),
),
)
}))

Check warning on line 65 in service/telemetry/logger.go

View check run for this annotation

Codecov / codecov/patch

service/telemetry/logger.go#L58-L65

Added lines #L58 - L65 were not covered by tests

}

if cfg.Sampling != nil && cfg.Sampling.Enabled {
Expand Down

0 comments on commit 7753636

Please sign in to comment.