Skip to content

Commit

Permalink
fix: do not use hardcoded AlwaysSample
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
  • Loading branch information
rustatian committed May 13, 2024
1 parent bb44be6 commit e2d76ba
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func (p *Plugin) Init(cfg Configurer, log Logger) error { //nolint:gocyclo
}

p.tracer = sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithBatcher(exporter),
sdktrace.WithResource(newResource(p.cfg.Resource, cfg.RRVersion())),
)
Expand All @@ -138,19 +137,15 @@ func (p *Plugin) Serve() chan error {
return make(chan error, 1)
}

func (p *Plugin) Stop(context.Context) error {
func (p *Plugin) Stop(ctx context.Context) error {
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#forceflush
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
err := p.tracer.ForceFlush(ctx)
if err != nil {
return err
}

// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#shutdown
ctx2, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
err = p.tracer.Shutdown(ctx2)
err = p.tracer.Shutdown(ctx)
if err != nil {
return err
}
Expand Down

0 comments on commit e2d76ba

Please sign in to comment.