1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

Use t.Cleanup instead of defer in stdouttrace (#7204)

Let the testing system ensure proper cleanup ordering and execution.
This commit is contained in:
Tyler Yahn
2025-08-18 03:35:54 -07:00
committed by GitHub
parent 4623d0a989
commit 3ca7996db3
+2 -2
View File
@@ -215,7 +215,7 @@ func expectedJSON(now time.Time) string {
func TestExporterShutdownIgnoresContext(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancel()
t.Cleanup(cancel)
e, err := stdouttrace.New()
if err != nil {
@@ -453,7 +453,7 @@ func TestSelfObservability(t *testing.T) {
}
original := otel.GetMeterProvider()
defer otel.SetMeterProvider(original)
t.Cleanup(func() { otel.SetMeterProvider(original) })
r := metric.NewManualReader()
mp := metric.NewMeterProvider(metric.WithReader(r))