I'm implementing tracing feature with otel's official sdk tracing pacakge in Golang. The link for its repository is here.
While TracerProvider
has all the configuraion such as Exporter
, SpanProcessor
, Sampler
..., we can still choose different Tracer
s from the same TracerProvider
:
tracerA := otel.GetTracerProvider().Tracer("TracerA")
tracerB := otel.GetTracerProvider().Tracer("TracerB")
Since they are from the same TracerProvider, tracerA and tracerB behave the same. And there's no other setting that makes difference. Example below will make one trace, not separated traces.
ctx, span := tracerA.Start(context.Background(), "First Span")
ctx, span = tracerB.start(ctx, "Second Span")
// above becomes
|----------------------| // First Span
|-------------| // Second Span
I wonder why otel
provides those different Tracer
instances. The result is the same no matter which Tracer
is used. Is there a use-case for it?