Skip to content

Commit

Permalink
Use trace/embedded in global impl
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Oct 13, 2023
1 parent 58fcab1 commit 33f2dd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/global/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
)

// tracerProvider is a placeholder for a configured SDK TracerProvider.
//
// All TracerProvider functionality is forwarded to a delegate once
// configured.
type tracerProvider struct {
embedded.TracerProvider

mtx sync.Mutex
tracers map[il]*tracer
delegate trace.TracerProvider
Expand Down Expand Up @@ -119,6 +122,8 @@ type il struct {
// All Tracer functionality is forwarded to a delegate once configured.
// Otherwise, all functionality is forwarded to a NoopTracer.
type tracer struct {
embedded.Tracer

name string
opts []trace.TracerOption
provider *tracerProvider
Expand Down Expand Up @@ -156,6 +161,8 @@ func (t *tracer) Start(ctx context.Context, name string, opts ...trace.SpanStart
// SpanContext. It performs no operations other than to return the wrapped
// SpanContext.
type nonRecordingSpan struct {
embedded.Span

sc trace.SpanContext
tracer *tracer
}
Expand Down
5 changes: 5 additions & 0 deletions internal/global/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ import (
"github.com/stretchr/testify/assert"

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

type fnTracerProvider struct {
embedded.TracerProvider

tracer func(string, ...trace.TracerOption) trace.Tracer
}

Expand All @@ -34,6 +37,8 @@ func (fn fnTracerProvider) Tracer(instrumentationName string, opts ...trace.Trac
}

type fnTracer struct {
embedded.Tracer

start func(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
}

Expand Down

0 comments on commit 33f2dd5

Please sign in to comment.