diff --git a/bridge/opentracing/provider.go b/bridge/opentracing/provider.go index b069753f7e9..3f093e75fcf 100644 --- a/bridge/opentracing/provider.go +++ b/bridge/opentracing/provider.go @@ -6,6 +6,7 @@ package opentracing // import "go.opentelemetry.io/otel/bridge/opentracing" import ( "sync" + "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace/embedded" ) @@ -38,6 +39,8 @@ func NewTracerProvider(bridge *BridgeTracer, provider trace.TracerProvider) *Tra type wrappedTracerKey struct { name string version string + schema string + attrs attribute.Set } // Tracer creates a WrappedTracer that wraps the OpenTelemetry tracer for each call to @@ -51,6 +54,8 @@ func (p *TracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.T key := wrappedTracerKey{ name: name, version: c.InstrumentationVersion(), + schema: c.SchemaURL(), + attrs: c.InstrumentationAttributes(), } if t, ok := p.tracers[key]; ok { diff --git a/bridge/opentracing/provider_test.go b/bridge/opentracing/provider_test.go index 0560e0230b5..7f6975b0132 100644 --- a/bridge/opentracing/provider_test.go +++ b/bridge/opentracing/provider_test.go @@ -6,6 +6,7 @@ package opentracing import ( "testing" + "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/bridge/opentracing/internal" "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace/embedded" @@ -64,11 +65,15 @@ func TestTracerProvider(t *testing.T) { assertMockTracerName(t, tracer2, foobar) tracer3 := provider.Tracer(bazbar) assertMockTracerName(t, tracer3, bazbar) + tracer4 := provider.Tracer(bazbar, trace.WithInstrumentationAttributes(attribute.String("foo", "bar"))) + assertMockTracerName(t, tracer4, bazbar) + tracer5 := provider.Tracer(bazbar, trace.WithSchemaURL("https://opentelemetry.io/schemas/1.2.0")) + assertMockTracerName(t, tracer5, bazbar) if tracer1 != tracer2 { t.Errorf("expected the same tracer, got different tracers") } - if tracer1 == tracer3 || tracer2 == tracer3 { + if tracer1 == tracer3 || tracer2 == tracer3 || tracer3 == tracer4 || tracer3 == tracer5 || tracer4 == tracer5 { t.Errorf("expected different tracers, got the same tracer") } })