You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-29 23:07:45 +02:00
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This commit is contained in:
@@ -195,3 +195,21 @@ func TestTracerDelegatesConcurrentSafe(t *testing.T) {
|
||||
|
||||
assert.LessOrEqual(t, int32(10), atomic.LoadInt32(&called), "expected configured TraceProvider to be called")
|
||||
}
|
||||
|
||||
func TestTraceProviderDelegatesSameInstance(t *testing.T) {
|
||||
global.ResetForTest()
|
||||
|
||||
// Retrieve the placeholder TracerProvider.
|
||||
gtp := otel.GetTracerProvider()
|
||||
tracer := gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz"))
|
||||
assert.Same(t, tracer, gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz")))
|
||||
assert.Same(t, tracer, gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz")))
|
||||
|
||||
otel.SetTracerProvider(fnTracerProvider{
|
||||
tracer: func(name string, opts ...trace.TracerOption) trace.Tracer {
|
||||
return trace.NewNoopTracerProvider().Tracer("")
|
||||
},
|
||||
})
|
||||
|
||||
assert.NotSame(t, tracer, gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user