Skip to content

Commit

Permalink
tracer: add test for logging 128-bit trace ids when upper bits are em…
Browse files Browse the repository at this point in the history
…pty (#2101)
  • Loading branch information
katiehockman committed Aug 17, 2023
1 parent 472db90 commit e9060fc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ddtrace/tracer/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,21 @@ func TestSpanLog(t *testing.T) {
v, _ := span.context.meta(keyTraceID128)
assert.Equal("0000000000000001", v)
})

t.Run("128-bit-logging-with-empty-upper-bits", func(t *testing.T) {
// Logging 128-bit trace ids is enabled, and but the upper 64 bits
// are empty, so the dd.trace_id should be printed as raw digits (not hex).
t.Setenv("DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED", "true")
assert := assert.New(t)
tracer, _, _, stop := startTestTracer(t, WithService("tracer.test"), WithEnv("testenv"))
defer stop()
span := tracer.StartSpan("test.request", WithSpanID(87654321)).(*span)
span.Finish()
assert.False(span.context.traceID.HasUpper()) // it should not have generated upper bits
assert.Equal(`dd.service=tracer.test dd.env=testenv dd.trace_id="87654321" dd.span_id="87654321" dd.parent_id="0"`, fmt.Sprintf("%v", span))
v, _ := span.context.meta(keyTraceID128)
assert.Equal("", v)
})
}

func TestRootSpanAccessor(t *testing.T) {
Expand Down

0 comments on commit e9060fc

Please sign in to comment.