From 3e39369707f0d41b098c872edf1b4ee6dfefa2ca Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Fri, 25 Oct 2024 07:50:02 -0700 Subject: [PATCH] Add TestNewSpanType --- internal/global/trace_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/global/trace_test.go b/internal/global/trace_test.go index 0eb34e3a3f64..80f3cbb89484 100644 --- a/internal/global/trace_test.go +++ b/internal/global/trace_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/assert" + "go.opentelemetry.io/auto/sdk" "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace/embedded" "go.opentelemetry.io/otel/trace/noop" @@ -271,3 +272,19 @@ func TestTracerIdentity(t *testing.T) { } } } + +func TestNewSpanType(t *testing.T) { + tracer := new(tracer) + ctx := context.Background() + _, got := tracer.newSpan(ctx, autoInstEnabled, "", nil) + assert.IsType(t, nonRecordingSpan{}, got, "default span type") + + orig := *autoInstEnabled + *autoInstEnabled = true + t.Cleanup(func() { *autoInstEnabled = orig }) + + _, got = tracer.newSpan(ctx, autoInstEnabled, "", nil) + autoTracer := sdk.GetTracerProvider().Tracer("") + _, span := autoTracer.Start(ctx, "") + assert.IsType(t, span, got, "auto span type") +}