diff --git a/ddtrace/tracer/textmap_test.go b/ddtrace/tracer/textmap_test.go index bd8800f484..9b67ef1ac3 100644 --- a/ddtrace/tracer/textmap_test.go +++ b/ddtrace/tracer/textmap_test.go @@ -2093,52 +2093,47 @@ func TestPropagatingTagsConcurrency(_ *testing.T) { } func TestMalformedTID(t *testing.T) { - assert := assert.New(t) + tracer := newTracer() + internal.SetGlobalTracer(tracer) + defer tracer.Stop() + defer internal.SetGlobalTracer(&internal.NoopTracer{}) + t.Run("datadog, short tid", func(t *testing.T) { - t.Setenv(headerPropagationStyleExtract, "datadog") - tracer := newTracer() - defer tracer.Stop() headers := TextMapCarrier(map[string]string{ DefaultTraceIDHeader: "1234567890123456789", DefaultParentIDHeader: "987654321", traceTagsHeader: "_dd.p.tid=1234567890abcde", }) sctx, err := tracer.Extract(headers) - assert.Nil(err) + assert.Nil(t, err) root := tracer.StartSpan("web.request", ChildOf(sctx)).(*span) root.Finish() - assert.NotContains(root.Meta, keyTraceID128) + assert.NotContains(t, root.Meta, keyTraceID128) }) t.Run("datadog, malformed tid", func(t *testing.T) { - t.Setenv(headerPropagationStyleExtract, "datadog") - tracer := newTracer() - defer tracer.Stop() headers := TextMapCarrier(map[string]string{ DefaultTraceIDHeader: "1234567890123456789", DefaultParentIDHeader: "987654321", traceTagsHeader: "_dd.p.tid=XXXXXXXXXXXXXXXX", }) sctx, err := tracer.Extract(headers) - assert.Nil(err) + assert.Nil(t, err) root := tracer.StartSpan("web.request", ChildOf(sctx)).(*span) root.Finish() - assert.NotContains(root.Meta, keyTraceID128) + assert.NotContains(t, root.Meta, keyTraceID128) }) t.Run("datadog, valid tid", func(t *testing.T) { - t.Setenv(headerPropagationStyleExtract, "datadog") - tracer := newTracer() - defer tracer.Stop() headers := TextMapCarrier(map[string]string{ DefaultTraceIDHeader: "1234567890123456789", DefaultParentIDHeader: "987654321", traceTagsHeader: "_dd.p.tid=640cfd8d00000000", }) sctx, err := tracer.Extract(headers) - assert.Nil(err) + assert.Nil(t, err) root := tracer.StartSpan("web.request", ChildOf(sctx)).(*span) root.Finish() - assert.Equal("640cfd8d00000000", root.Meta[keyTraceID128]) + assert.Equal(t, "640cfd8d00000000", root.Meta[keyTraceID128]) }) } diff --git a/ddtrace/tracer/tracer_test.go b/ddtrace/tracer/tracer_test.go index 1d6bb90db2..91829844d6 100644 --- a/ddtrace/tracer/tracer_test.go +++ b/ddtrace/tracer/tracer_test.go @@ -712,8 +712,9 @@ func TestTracerStartSpanOptions128(t *testing.T) { tracer := newTracer() internal.SetGlobalTracer(tracer) defer tracer.Stop() - assert := assert.New(t) + defer internal.SetGlobalTracer(&internal.NoopTracer{}) t.Run("64-bit-trace-id", func(t *testing.T) { + assert := assert.New(t) opts := []StartSpanOption{ WithSpanID(987654), } @@ -728,6 +729,7 @@ func TestTracerStartSpanOptions128(t *testing.T) { assert.Equal(s.Context().TraceID(), binary.BigEndian.Uint64(idBytes[8:])) }) t.Run("128-bit-trace-id", func(t *testing.T) { + assert := assert.New(t) // Enable 128 bit trace ids t.Setenv("DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED", "true") opts128 := []StartSpanOption{