Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,9 @@ public static void enableOpenCensusTraces() {
+ " OpenTelemetry traces")
@VisibleForTesting
static void resetActiveTracingFramework() {
activeTracingFramework = null;
synchronized (lock) {
activeTracingFramework = null;
}
}

public static TracingFramework getActiveTracingFramework() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.time.Duration;
import java.util.Collections;
import java.util.Map;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -71,6 +72,11 @@ public static void setupOpenTelemetry() {
SpannerOptions.enableOpenTelemetryTraces();
}

@AfterClass
public static void resetOpenTelemetry() {
SpannerOptions.resetActiveTracingFramework();
}
Comment thread
olavloite marked this conversation as resolved.
Resolved

@SuppressWarnings("unchecked")
@Before
public void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public SpannerOptions spannerOptionsWithEndToEndTracing(SpannerOptions options)
.setTracerProvider(sdkTracerProvider)
.setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance()))
.build();
SpannerOptions.resetActiveTracingFramework();
SpannerOptions.enableOpenTelemetryTraces();
return options.toBuilder()
.setOpenTelemetry(openTelemetry)
Expand All @@ -217,8 +218,15 @@ RemoteSpannerHelper createTestHelper(SpannerOptions options, InstanceId instance

@Override
protected void after() {
cleanUpInstance();
this.config.tearDown();
try {
cleanUpInstance();
} finally {
try {
this.config.tearDown();
} finally {
SpannerOptions.resetActiveTracingFramework();
}
}
Comment thread
olavloite marked this conversation as resolved.
Resolved
}

private void initializeInstance(InstanceId instanceId) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static class BenchmarkState {

@Setup(Level.Iteration)
public void setup() throws Exception {
SpannerOptions.resetActiveTracingFramework();
SpannerOptions.enableOpenTelemetryMetrics();
SpannerOptions.enableOpenTelemetryTraces();
SpannerOptions options =
Expand All @@ -109,7 +110,11 @@ public void setup() throws Exception {

@TearDown(Level.Iteration)
public void teardown() throws Exception {
spanner.close();
try {
spanner.close();
} finally {
SpannerOptions.resetActiveTracingFramework();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Ignore;
Expand Down Expand Up @@ -97,6 +98,11 @@ public static void setupOpenTelemetry() throws Exception {
field.set(null, failOnOverkillTraceComponent);
}

@AfterClass
public static void resetTracing() {
SpannerOptions.resetActiveTracingFramework();
}

@BeforeClass
public static void setupResults() {
RandomResultSetGenerator generator = new RandomResultSetGenerator(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public static void setupResults() {

@AfterClass
public static void closeOpenTelemetry() {
SpannerOptions.resetActiveTracingFramework();
if (openTelemetry != null) {
openTelemetry.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public static void startStaticServer() throws Exception {

@AfterClass
public static void stopServer() throws InterruptedException {
SpannerOptions.resetActiveTracingFramework();
if (server != null) {
server.shutdown();
server.awaitTermination();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nullable;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -100,6 +101,11 @@ public static void setupOpenTelemetry() {
SpannerOptions.enableOpenTelemetryTraces();
}

@AfterClass
public static void resetOpenTelemetry() {
SpannerOptions.resetActiveTracingFramework();
}

@SuppressWarnings("unchecked")
@Before
public void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public static void startStaticServer() throws Exception {

@AfterClass
public static void stopServer() throws InterruptedException {
SpannerOptions.resetActiveTracingFramework();
if (server != null) {
server.shutdown();
server.awaitTermination();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -81,6 +82,11 @@ public static void setupOpenTelemetry() {
SpannerOptions.enableOpenTelemetryTraces();
}

@AfterClass
public static void resetOpenTelemetry() {
SpannerOptions.resetActiveTracingFramework();
}

@Before
public void setUp() {
databaseAdminStubSettings =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -89,6 +90,11 @@ public static void setupOpenTelemetry() {
SpannerOptions.enableOpenTelemetryTraces();
}

@AfterClass
public static void resetOpenTelemetry() {
SpannerOptions.resetActiveTracingFramework();
}

@Before
public void setUp() {
initMocks(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -115,6 +116,11 @@ public static void setupOpenTelemetry() {
SpannerOptions.enableOpenTelemetryTraces();
}

@AfterClass
public static void resetOpenTelemetry() {
SpannerOptions.resetActiveTracingFramework();
}

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static void setupOpenTelemetry() {

@AfterClass
public static void closeOpenTelemetry() {
SpannerOptionsTestHelper.resetActiveTracingFramework();
SpannerPool.closeSpannerPool();
if (openTelemetry != null) {
openTelemetry.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ public static void setUpDatabase() {

@AfterClass
public static void teardown() {
ConnectionOptions.closeSpanner();
try {
ConnectionOptions.closeSpanner();
} finally {
SpannerOptionsHelper.resetActiveTracingFramework();
}
}

private void assertTrace(String traceId) throws IOException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(

@After
public void reset() throws InterruptedException {
SpannerOptionsHelper.resetActiveTracingFramework();
if (mockSpanner != null) {
mockSpanner.reset();
}
Expand Down
Loading