This test starts a set of goroutines which do things to spans after
they have finished. Wait for these goroutines to complete before
ending the test function. This ensures these goroutines are not
running when other tests run. This avoids these tests accidentally
capturing the logs from these goroutines, and avoids the race
detector triggering on things they are doing.
This fixes a problem when running tests with -shuffle=on, and also
fixes a race detector warning:
==================
WARNING: DATA RACE
Write at 0x000103d80470 by goroutine 74703:
gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer.setTestTime()
/Users/evan.jones/dd/dd-trace-go/ddtrace/tracer/abandonedspans_test.go:28 +0xf8
gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer.TestReportAbandonedSpans.func2()
/Users/evan.jones/dd/dd-trace-go/ddtrace/tracer/abandonedspans_test.go:81 +0x44
testing.tRunner()
/opt/homebrew/Cellar/go/1.21.2/libexec/src/testing/testing.go:1595 +0x194
testing.(*T).Run.func1()
/opt/homebrew/Cellar/go/1.21.2/libexec/src/testing/testing.go:1648 +0x40
Previous read at 0x000103d80470 by goroutine 74356:
gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer.(*span).Finish()
/Users/evan.jones/dd/dd-trace-go/ddtrace/tracer/span.go:423 +0x3c
gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer.TestUserMonitoring.func5.2()
/Users/evan.jones/dd/dd-trace-go/ddtrace/tracer/tracer_test.go:2331 +0xc4
Goroutine 74703 (running) created at:
testing.(*T).Run()
/opt/homebrew/Cellar/go/1.21.2/libexec/src/testing/testing.go:1648 +0x5d8
gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer.TestReportAbandonedSpans()
/Users/evan.jones/dd/dd-trace-go/ddtrace/tracer/abandonedspans_test.go:79 +0x204
testing.tRunner()
/opt/homebrew/Cellar/go/1.21.2/libexec/src/testing/testing.go:1595 +0x194
testing.(*T).Run.func1()
/opt/homebrew/Cellar/go/1.21.2/libexec/src/testing/testing.go:1648 +0x40
Goroutine 74356 (running) created at:
gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer.TestUserMonitoring.func5()
/Users/evan.jones/dd/dd-trace-go/ddtrace/tracer/tracer_test.go:2329 +0x154
testing.tRunner()
/opt/homebrew/Cellar/go/1.21.2/libexec/src/testing/testing.go:1595 +0x194
testing.(*T).Run.func1()
/opt/homebrew/Cellar/go/1.21.2/libexec/src/testing/testing.go:1648 +0x40
==================