@@ -13,6 +13,7 @@ import (
1313 "github.com/segmentio/encoding/json"
1414 "github.com/stretchr/testify/assert"
1515 "github.com/stretchr/testify/require"
16+ "go.opentelemetry.io/otel/trace"
1617 "go.uber.org/goleak"
1718
1819 "github.com/shortlink-org/go-sdk/logger"
@@ -293,7 +294,18 @@ func TestDebugWithContext(t *testing.T) {
293294 log , err := logger .New (conf )
294295 require .NoError (t , err )
295296
296- ctx := context .WithValue (context .Background (), sessionIDKey , "sess-789" )
297+ traceID , err := trace .TraceIDFromHex ("01020304050607080102030405060708" )
298+ require .NoError (t , err )
299+ spanID , err := trace .SpanIDFromHex ("0102030405060708" )
300+ require .NoError (t , err )
301+
302+ spanCtx := trace .NewSpanContext (trace.SpanContextConfig {
303+ TraceID : traceID ,
304+ SpanID : spanID ,
305+ TraceFlags : trace .FlagsSampled ,
306+ })
307+
308+ ctx := context .WithValue (trace .ContextWithSpanContext (context .Background (), spanCtx ), sessionIDKey , "sess-789" )
297309 log .DebugWithContext (ctx , "Processing step" , slog .String ("step" , "validation" ), slog .Int ("data_size" , 1024 ))
298310
299311 require .Contains (t , buffer .String (), `"level":"DEBUG"` )
0 commit comments