From 33f2dd58ccf585809507e55c91a50961277759b2 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Thu, 12 Oct 2023 14:18:12 -0700 Subject: [PATCH] Use trace/embedded in global impl --- internal/global/trace.go | 7 +++++++ internal/global/trace_test.go | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/internal/global/trace.go b/internal/global/trace.go index 5f008d0982b..3f61ec12a34 100644 --- a/internal/global/trace.go +++ b/internal/global/trace.go @@ -39,6 +39,7 @@ 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. @@ -46,6 +47,8 @@ import ( // 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 @@ -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 @@ -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 } diff --git a/internal/global/trace_test.go b/internal/global/trace_test.go index f8f9149d9e0..6b1cd5f90f6 100644 --- a/internal/global/trace_test.go +++ b/internal/global/trace_test.go @@ -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 } @@ -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) }