From 9a330d03e7fca561e10e98d47fcfdf2061c716fc Mon Sep 17 00:00:00 2001 From: John Watson Date: Tue, 6 Apr 2021 17:12:41 -0700 Subject: [PATCH] Make the test extensions defensively reset the GlobalOpenTelemetry instance before setting. (#3110) --- .../io/opentelemetry/sdk/testing/junit4/OpenTelemetryRule.java | 1 + .../opentelemetry/sdk/testing/junit5/OpenTelemetryExtension.java | 1 + 2 files changed, 2 insertions(+) diff --git a/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/junit4/OpenTelemetryRule.java b/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/junit4/OpenTelemetryRule.java index e47fa145763..03a2cba0161 100644 --- a/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/junit4/OpenTelemetryRule.java +++ b/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/junit4/OpenTelemetryRule.java @@ -92,6 +92,7 @@ public void clearSpans() { @Override protected void before() { + GlobalOpenTelemetry.resetForTest(); GlobalOpenTelemetry.set(openTelemetry); clearSpans(); } diff --git a/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/junit5/OpenTelemetryExtension.java b/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/junit5/OpenTelemetryExtension.java index 651b1e68b3e..55110c47d5d 100644 --- a/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/junit5/OpenTelemetryExtension.java +++ b/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/junit5/OpenTelemetryExtension.java @@ -120,6 +120,7 @@ public void beforeEach(ExtensionContext context) { @Override public void beforeAll(ExtensionContext context) { + GlobalOpenTelemetry.resetForTest(); GlobalOpenTelemetry.set(openTelemetry); }