Skip to content

Commit

Permalink
bridge/opentracing: rename constructor to NewTracerProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Sep 1, 2022
1 parent 8a83e1f commit 59f2c6b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions bridge/opentracing/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ type WrapperTracerProvider struct {

var _ trace.TracerProvider = (*WrapperTracerProvider)(nil)

// Tracer returns the WrapperTracer associated with the WrapperTracerProvider.
// Tracer creates a WrapperTracer associated with the WrapperTracerProvider.
func (p *WrapperTracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.Tracer {
return p.getWrappedTracer(name, opts...)
}

// Deprecated: Use NewTracerProvider(...) instead.
//
// NewWrappedTracerProvider creates a new trace provider that creates a single
// instance of WrapperTracer that wraps OpenTelemetry tracer, and always returns
// it unmodified from Tracer().
Expand All @@ -52,9 +54,9 @@ type wrappedTracerKey struct {
version string
}

// NewDynamicWrappedTracerProvider creates a new trace provider that creates new
// instances of WrapperTracer that wraps OpenTelemetry tracer for each call to Tracer().
func NewDynamicWrappedTracerProvider(bridge *BridgeTracer, provider trace.TracerProvider) *WrapperTracerProvider {
// NewTracerProvider creates a new trace provider that creates new instances of
// WrapperTracer that wraps OpenTelemetry tracer for each call to Tracer().
func NewTracerProvider(bridge *BridgeTracer, provider trace.TracerProvider) *WrapperTracerProvider {
var (
mtx sync.Mutex
tracers = make(map[wrappedTracerKey]*WrapperTracer)
Expand Down
4 changes: 2 additions & 2 deletions bridge/opentracing/wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (p *namedMockTracerProvider) Tracer(name string, opts ...trace.TracerOption
}
}

func TestDynamicWrappedTracerProvider(t *testing.T) {
func TestTracerProvider(t *testing.T) {
// assertMockTracerName casts tracer into a named mock tracer provided by
// namedMockTracerProvider, and asserts against its name
assertMockTracerName := func(t *testing.T, tracer trace.Tracer, name string) {
Expand All @@ -45,7 +45,7 @@ func TestDynamicWrappedTracerProvider(t *testing.T) {
var (
foobar = "foobar"
bazbar = "bazbar"
provider = NewDynamicWrappedTracerProvider(nil, &namedMockTracerProvider{})
provider = NewTracerProvider(nil, &namedMockTracerProvider{})
)

t.Run("Tracers should be created with foobar from provider", func(t *testing.T) {
Expand Down

0 comments on commit 59f2c6b

Please sign in to comment.