Skip to content

Commit 4ad9904

Browse files
committed
fix(contrib/gin): fix TestServiceName test ordering issue
The TestServiceName test was failing when run with certain shuffle seeds, e.g.: test -test.shuffle 1761392205507602000 ./contrib/gin-gonic/gin/ This was caused by TestTracerStartedMultipleTimes setting a global service name without restoring the old one. Fix the problem by making TestTracerStartedMultipleTimes clean up after itself.
1 parent 5dcec1a commit 4ad9904

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contrib/gin-gonic/gin/gintrace_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,10 @@ func TestServiceName(t *testing.T) {
649649
// TestTracerStartedMultipleTimes tests a v2 regression where the global service name was being set to an empty string
650650
// when the tracer is started more than once.
651651
func TestTracerStartedMultipleTimes(t *testing.T) {
652+
// tracer.WithService below overwrites the global service name, this call
653+
// ensures we restore it its previous value after this test finishes.
654+
testutils.SetGlobalServiceName(t, "")
655+
652656
tt1 := testtracer.Start(t)
653657
defer tt1.Stop()
654658
tt2 := testtracer.Start(t, testtracer.WithTracerStartOpts(tracer.WithService("global_service")))

0 commit comments

Comments
 (0)