Skip to content

Commit b567ff6

Browse files
committed
perf(gax): reuse static NOOP_SCOPE in OpenTelemetryTracingTracer
1 parent e6ec8c9 commit b567ff6

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing/OpenTelemetryTracingTracer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ class OpenTelemetryTracingTracer implements ApiTracer {
5454
private final ApiTracerContext apiTracerContext;
5555
private @Nullable Span attemptSpan;
5656

57+
private static final Scope NOOP_SCOPE = () -> {};
58+
5759
@Override
5860
@SuppressWarnings("deprecation")
5961
public Scope inScope() {
6062
if (attemptSpan == null) {
61-
return () -> {};
63+
return NOOP_SCOPE;
6264
}
6365
@SuppressWarnings("MustBeClosedChecker")
6466
io.opentelemetry.context.Scope otelScope = attemptSpan.makeCurrent();

0 commit comments

Comments
 (0)