Skip to content

Commit

Permalink
Use extension logger for collector (open-telemetry#400)
Browse files Browse the repository at this point in the history
This will cause the collector to use the same verbosity
and JSON output format as the rest of the logs produced
by the extension.

Signed-off-by: Anthony J Mirabella <[email protected]>

Signed-off-by: Anthony J Mirabella <[email protected]>
  • Loading branch information
Aneurysm9 authored Jan 6, 2023
1 parent 60b6529 commit 98b7824
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"go.opentelemetry.io/collector/confmap/provider/yamlprovider"
"go.opentelemetry.io/collector/otelcol"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

var (
Expand All @@ -48,6 +49,7 @@ type Collector struct {
svc *otelcol.Collector
appDone chan struct{}
stopped bool
logger *zap.Logger
}

func getConfig(logger *zap.Logger) string {
Expand Down Expand Up @@ -84,6 +86,7 @@ func NewCollector(logger *zap.Logger, factories component.Factories) *Collector
col := &Collector{
factories: factories,
configProvider: cfgProvider,
logger: logger,
}
return col
}
Expand All @@ -97,6 +100,9 @@ func (c *Collector) Start(ctx context.Context) error {
},
ConfigProvider: c.configProvider,
Factories: c.factories,
LoggingOptions: []zap.Option{zap.WrapCore(func(_ zapcore.Core) zapcore.Core {
return c.logger.Core()
})},
}
var err error
c.svc, err = otelcol.NewCollector(params)
Expand Down

0 comments on commit 98b7824

Please sign in to comment.