Skip to content

Commit

Permalink
Update opentracing bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Oct 13, 2023
1 parent ef36d11 commit 50c3d0e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bridge/opentracing/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ import (
iBaggage "go.opentelemetry.io/otel/internal/baggage"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
)

var (
noopTracer = trace.NewNoopTracerProvider().Tracer("")
noopTracer = noop.NewTracerProvider().Tracer("")
noopSpan = func() trace.Span {
_, s := noopTracer.Start(context.Background(), "")
return s
Expand Down
8 changes: 7 additions & 1 deletion bridge/opentracing/internal/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"go.opentelemetry.io/otel/codes"
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
"go.opentelemetry.io/otel/trace/noop"
)

//nolint:revive // ignoring missing comments for unexported global variables in an internal package.
Expand All @@ -44,6 +46,8 @@ type MockContextKeyValue struct {
}

type MockTracer struct {
embedded.Tracer

FinishedSpans []*MockSpan
SpareTraceIDs []trace.TraceID
SpareSpanIDs []trace.SpanID
Expand Down Expand Up @@ -182,6 +186,8 @@ type MockEvent struct {
}

type MockSpan struct {
embedded.Span

mockTracer *MockTracer
officialTracer trace.Tracer
spanContext trace.SpanContext
Expand Down Expand Up @@ -291,4 +297,4 @@ func (s *MockSpan) OverrideTracer(tracer trace.Tracer) {
s.officialTracer = tracer
}

func (s *MockSpan) TracerProvider() trace.TracerProvider { return trace.NewNoopTracerProvider() }
func (s *MockSpan) TracerProvider() trace.TracerProvider { return noop.NewTracerProvider() }
3 changes: 3 additions & 0 deletions bridge/opentracing/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ import (
"sync"

"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
)

// TracerProvider is an OpenTelemetry TracerProvider that wraps an OpenTracing
// Tracer.
type TracerProvider struct {
embedded.TracerProvider

bridge *BridgeTracer
provider trace.TracerProvider

Expand Down
3 changes: 2 additions & 1 deletion bridge/opentracing/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import (

"go.opentelemetry.io/otel/bridge/opentracing/internal"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
)

type namedMockTracer struct {
name string
*internal.MockTracer
}

type namedMockTracerProvider struct{}
type namedMockTracerProvider struct{ embedded.TracerProvider }

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

Expand Down
5 changes: 5 additions & 0 deletions bridge/opentracing/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ import (

"go.opentelemetry.io/otel/bridge/opentracing/migration"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
)

// WrapperTracerProvider is an OpenTelemetry TracerProvider that wraps an
// OpenTracing Tracer, created by the deprecated NewWrappedTracerProvider.
//
// Deprecated: Use the TracerProvider from NewTracerProvider(...) instead.
type WrapperTracerProvider struct {
embedded.TracerProvider

wTracer *WrapperTracer
}

Expand Down Expand Up @@ -56,6 +59,8 @@ func NewWrappedTracerProvider(bridge *BridgeTracer, tracer trace.Tracer) *Wrappe
// aware how to operate in environment where OpenTracing API is also
// used.
type WrapperTracer struct {
embedded.Tracer

bridge *BridgeTracer
tracer trace.Tracer
}
Expand Down

0 comments on commit 50c3d0e

Please sign in to comment.