Skip to content

Commit

Permalink
Add TestNewSpanType
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Oct 25, 2024
1 parent 38ddafd commit 3e39369
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/global/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}

0 comments on commit 3e39369

Please sign in to comment.