Skip to content

Commit 5dcec1a

Browse files
committed
fix(contrib slog/logrus): fix for shuffle testing
Fix slog and logrus to pass their test suite when shuffle testing is enabled. In particular, fix the following two test invocations. go test -test.shuffle 1761195191840193457 ./contrib/log/slog/ go test -test.shuffle 176139568378992735 ./contrib/sirupsen/logrus/ -count 2
1 parent 56a1413 commit 5dcec1a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

contrib/log/slog/slog_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ func testLogger(t *testing.T, createLogger func(b io.Writer) *slog.Logger, asser
8484
spanID := strconv.FormatUint(span.Context().SpanID(), 10)
8585
if os.Getenv("DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED") == "false" {
8686
// Re-initialize to account for race condition between setting env var in the test and reading it in the contrib
87+
oldCfg := cfg
88+
t.Cleanup(func() { cfg = oldCfg })
8789
cfg = newConfig()
8890
traceID = strconv.FormatUint(span.Context().TraceIDLower(), 10)
8991
} else {

contrib/sirupsen/logrus/logrus_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ func TestFire128BitDisabled(t *testing.T) {
3636
t.Setenv("DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED", "false")
3737

3838
// Re-initialize to account for race condition between setting env var in the test and reading it in the contrib
39+
oldCfg := cfg
40+
t.Cleanup(func() { cfg = oldCfg })
3941
cfg = newConfig()
4042

4143
tracer.Start()

0 commit comments

Comments
 (0)