Skip to content

Commit

Permalink
nit: simplify TraceProvider initialization in one step (#5570)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Jun 22, 2022
1 parent 408f1e9 commit 388c117
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"go.opentelemetry.io/otel/metric/nonrecording"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
"go.uber.org/multierr"

"go.opentelemetry.io/collector/component"
Expand All @@ -43,9 +42,12 @@ func newService(set *settings) (*service, error) {
buildInfo: set.BuildInfo,
config: set.Config,
telemetry: component.TelemetrySettings{
TracerProvider: trace.NewNoopTracerProvider(),
MeterProvider: nonrecording.NewNoopMeterProvider(),
MetricsLevel: set.Config.Telemetry.Metrics.Level,
TracerProvider: sdktrace.NewTracerProvider(
// needed for supporting the zpages extension
sdktrace.WithSampler(internal.AlwaysRecord()),
),
MeterProvider: nonrecording.NewNoopMeterProvider(),
MetricsLevel: set.Config.Telemetry.Metrics.Level,
},
host: &serviceHost{
factories: set.Factories,
Expand All @@ -54,11 +56,6 @@ func newService(set *settings) (*service, error) {
},
}

srv.telemetry.TracerProvider = sdktrace.NewTracerProvider(
// needed for supporting the zpages extension
sdktrace.WithSampler(internal.AlwaysRecord()),
)

var err error
if srv.telemetry.Logger, err = telemetrylogs.NewLogger(set.Config.Service.Telemetry.Logs, set.LoggingOptions); err != nil {
return nil, fmt.Errorf("failed to get logger: %w", err)
Expand Down

0 comments on commit 388c117

Please sign in to comment.