Skip to content

Commit

Permalink
Use BatchSpanProcessor instead of SimpleSpanProcessor (#24)
Browse files Browse the repository at this point in the history
As reported by @milanaleksic, the launcher was configured to use the SimpleSpanProcessor
which was affecting application performance. This change updates the launcher to
configure the BatchSpanProcessor by default.
  • Loading branch information
alrex authored Oct 14, 2020
1 parent 9b592ca commit 3002a04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,10 @@ func setupTracing(c Config) (func() error, error) {
return nil, fmt.Errorf("failed to create span exporter: %v", err)
}

bsp := trace.NewBatchSpanProcessor(spanExporter)
tp := trace.NewTracerProvider(
trace.WithConfig(trace.Config{DefaultSampler: trace.AlwaysSample()}),
trace.WithSyncer(spanExporter),
trace.WithSpanProcessor(bsp),
trace.WithResource(c.Resource),
)

Expand All @@ -374,6 +375,7 @@ func setupTracing(c Config) (func() error, error) {
global.SetTracerProvider(tp)

return func() error {
bsp.Shutdown()
return spanExporter.Shutdown(context.Background())
}, nil
}
Expand Down
3 changes: 2 additions & 1 deletion launcher/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ func TestConfigurePropagators(t *testing.T) {
prop = global.TextMapPropagator()
prop.Inject(ctx, carrier)
assert.Greater(t, len(carrier.Get("x-b3-traceid")), 0)
assert.Equal(t, "keyone=foo1,keytwo=bar1", carrier.Get("otcorrelations"))
assert.Contains(t, carrier.Get("otcorrelations"), "keytwo=bar1")
assert.Contains(t, carrier.Get("otcorrelations"), "keyone=foo1")

logger = &testLogger{}
lsOtel = ConfigureOpentelemetry(
Expand Down

0 comments on commit 3002a04

Please sign in to comment.