-
Notifications
You must be signed in to change notification settings - Fork 69
feat(observability): add no-op implementation of tracing #4045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
diegomarquezp
wants to merge
10
commits into
main
Choose a base branch
from
observability/tracing-noop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e01ca06
feat(observability): add no-op implementation of tracing
diegomarquezp d3f61d1
chore: add otel tracing recorder
diegomarquezp cf98e86
chore: add javadocs
diegomarquezp 523c301
chore: adjust tests and conform more closely to metrics counterpart.
diegomarquezp d9534bd
chore: expand imports in otel it
diegomarquezp 196d591
Update gax-java/gax/src/main/java/com/google/api/gax/tracing/OpenTele…
diegomarquezp ea075d3
test: use tracer provider in ItOtelMetrics
diegomarquezp 2997153
Merge branch 'observability/tracing-noop' of https://github.com/googl…
diegomarquezp 2c26971
chore: format
diegomarquezp 1a76c29
chore: generate libraries at Thu Jan 8 19:39:27 UTC 2026
cloud-java-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
gax-java/gax/src/main/java/com/google/api/gax/tracing/OpenTelemetryTracingRecorder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are | ||
| * met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following disclaimer | ||
| * in the documentation and/or other materials provided with the | ||
| * distribution. | ||
| * * Neither the name of Google LLC nor the names of its | ||
| * contributors may be used to endorse or promote products derived from | ||
| * this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| package com.google.api.gax.tracing; | ||
|
|
||
| import com.google.api.core.BetaApi; | ||
| import com.google.api.core.InternalApi; | ||
| import io.opentelemetry.api.OpenTelemetry; | ||
|
|
||
| /** | ||
| * OpenTelemetry implementation of recording traces. This implementation collects the measurements | ||
| * related to the lifecyle of an RPC. | ||
| */ | ||
| @BetaApi | ||
| @InternalApi | ||
| public class OpenTelemetryTracingRecorder implements TracingRecorder { | ||
| private final OpenTelemetry openTelemetry; | ||
| private final String serviceName; | ||
|
|
||
| /** | ||
| * Creates a new instance of OpenTelemetryTracingRecorder. | ||
| * | ||
| * @param openTelemetry OpenTelemetry instance | ||
| * @param serviceName Service Name | ||
| */ | ||
| public OpenTelemetryTracingRecorder(OpenTelemetry openTelemetry, String serviceName) { | ||
| this.openTelemetry = openTelemetry; | ||
| this.serviceName = serviceName; | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
gax-java/gax/src/main/java/com/google/api/gax/tracing/TracingRecorder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are | ||
| * met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following disclaimer | ||
| * in the documentation and/or other materials provided with the | ||
| * distribution. | ||
| * * Neither the name of Google LLC nor the names of its | ||
| * contributors may be used to endorse or promote products derived from | ||
| * this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| package com.google.api.gax.tracing; | ||
|
|
||
| import com.google.api.core.BetaApi; | ||
| import com.google.api.core.InternalApi; | ||
|
|
||
| /** | ||
| * Provides an interface for tracing recording. The implementer is expected to use an observability | ||
| * framework, e.g. OpenTelemetry. There should be only one instance of TracingRecorder per client, | ||
| * all the methods in this class are expected to be called from multiple threads, hence the | ||
| * implementation must be thread safe. | ||
| */ | ||
| @BetaApi | ||
| @InternalApi | ||
| public interface TracingRecorder { | ||
| // Minimal working feature: noop implementation for now. | ||
| } |
49 changes: 49 additions & 0 deletions
49
gax-java/gax/src/main/java/com/google/api/gax/tracing/TracingTracer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are | ||
| * met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following disclaimer | ||
| * in the documentation and/or other materials provided with the | ||
| * distribution. | ||
| * * Neither the name of Google LLC nor the names of its | ||
| * contributors may be used to endorse or promote products derived from | ||
| * this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| package com.google.api.gax.tracing; | ||
|
|
||
| import com.google.api.core.BetaApi; | ||
| import com.google.api.core.InternalApi; | ||
|
|
||
| /** | ||
| * This class computes generic traces that can be observed in the lifecycle of an RPC operation. The | ||
| * responsibility of recording traces should delegate to {@link TracingRecorder}, hence this class | ||
| * should not have any knowledge about the observability framework used for tracing recording. | ||
| */ | ||
| @BetaApi | ||
| @InternalApi | ||
| public class TracingTracer extends BaseApiTracer { | ||
| private final TracingRecorder tracingRecorder; | ||
|
|
||
| public TracingTracer(TracingRecorder tracingRecorder) { | ||
| this.tracingRecorder = tracingRecorder; | ||
| } | ||
| } |
75 changes: 75 additions & 0 deletions
75
gax-java/gax/src/main/java/com/google/api/gax/tracing/TracingTracerFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are | ||
| * met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following disclaimer | ||
| * in the documentation and/or other materials provided with the | ||
| * distribution. | ||
| * * Neither the name of Google LLC nor the names of its | ||
| * contributors may be used to endorse or promote products derived from | ||
| * this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| package com.google.api.gax.tracing; | ||
|
|
||
| import com.google.api.core.BetaApi; | ||
| import com.google.api.core.InternalApi; | ||
| import com.google.common.collect.ImmutableMap; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * A {@link ApiTracerFactory} to build instances of {@link TracingTracer}. | ||
| * | ||
| * <p>This class wraps the {@link TracingRecorder} and pass it to {@link TracingTracer}. It will be | ||
| * used to record traces in {@link TracingTracer}. | ||
| * | ||
| * <p>This class is expected to be initialized once during client initialization. | ||
| */ | ||
| @BetaApi | ||
| @InternalApi | ||
| public class TracingTracerFactory implements ApiTracerFactory { | ||
| protected TracingRecorder tracingRecorder; | ||
|
|
||
| /** Mapping of client attributes that are set for every TracingTracer */ | ||
| private final Map<String, String> attributes; | ||
diegomarquezp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** Creates a TracingTracerFactory with no additional client level attributes. */ | ||
| public TracingTracerFactory(TracingRecorder tracingRecorder) { | ||
| this(tracingRecorder, ImmutableMap.of()); | ||
| } | ||
|
|
||
| /** | ||
| * Pass in a Map of client level attributes which will be added to every single TracingTracer | ||
| * created from the ApiTracerFactory. | ||
| */ | ||
| public TracingTracerFactory(TracingRecorder tracingRecorder, Map<String, String> attributes) { | ||
| this.tracingRecorder = tracingRecorder; | ||
| this.attributes = ImmutableMap.copyOf(attributes); | ||
| } | ||
|
|
||
| @Override | ||
| public ApiTracer newTracer(ApiTracer parent, SpanName spanName, OperationType operationType) { | ||
| if (!TracingUtils.isTracingEnabled()) { | ||
| return BaseApiTracer.getInstance(); | ||
| } | ||
| return new TracingTracer(tracingRecorder); | ||
| } | ||
| } | ||
59 changes: 59 additions & 0 deletions
59
gax-java/gax/src/main/java/com/google/api/gax/tracing/TracingUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are | ||
| * met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following disclaimer | ||
| * in the documentation and/or other materials provided with the | ||
| * distribution. | ||
| * * Neither the name of Google LLC nor the names of its | ||
| * contributors may be used to endorse or promote products derived from | ||
| * this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| package com.google.api.gax.tracing; | ||
|
|
||
| import com.google.api.core.InternalApi; | ||
| import com.google.common.annotations.VisibleForTesting; | ||
|
|
||
| /** Internal utility class to manage tracing configuration. */ | ||
| @InternalApi | ||
| public class TracingUtils { | ||
| static final String GOOGLE_CLOUD_ENABLE_TRACING = "GOOGLE_CLOUD_ENABLE_TRACING"; | ||
|
|
||
| private TracingUtils() {} | ||
|
|
||
| /** | ||
| * Returns true if tracing is enabled via the GOOGLE_CLOUD_ENABLE_TRACING environment variable or | ||
| * system property. | ||
| */ | ||
| public static boolean isTracingEnabled() { | ||
| String enableTracing = System.getProperty(GOOGLE_CLOUD_ENABLE_TRACING); | ||
| if (enableTracing == null) { | ||
| enableTracing = System.getenv(GOOGLE_CLOUD_ENABLE_TRACING); | ||
| } | ||
| return isTracingEnabled(enableTracing); | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| static boolean isTracingEnabled(String envValue) { | ||
| return "true".equalsIgnoreCase(envValue); | ||
| } | ||
| } |
79 changes: 79 additions & 0 deletions
79
gax-java/gax/src/test/java/com/google/api/gax/tracing/TracingTracerFactoryTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are | ||
| * met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following disclaimer | ||
| * in the documentation and/or other materials provided with the | ||
| * distribution. | ||
| * * Neither the name of Google LLC nor the names of its | ||
| * contributors may be used to endorse or promote products derived from | ||
| * this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| package com.google.api.gax.tracing; | ||
|
|
||
| import static com.google.common.truth.Truth.assertThat; | ||
| import static org.mockito.Mockito.mock; | ||
|
|
||
| import com.google.api.gax.tracing.ApiTracerFactory.OperationType; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class TracingTracerFactoryTest { | ||
| private TracingRecorder tracingRecorder; | ||
| private TracingTracerFactory factory; | ||
| private ApiTracer parent; | ||
| private SpanName spanName; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| tracingRecorder = mock(TracingRecorder.class); | ||
| factory = new TracingTracerFactory(tracingRecorder); | ||
| parent = mock(ApiTracer.class); | ||
| spanName = mock(SpanName.class); | ||
| } | ||
|
|
||
| @AfterEach | ||
| void tearDown() { | ||
| System.clearProperty("GOOGLE_CLOUD_ENABLE_TRACING"); | ||
| } | ||
|
|
||
| @Test | ||
| void testNewTracer_enabled() { | ||
| System.setProperty("GOOGLE_CLOUD_ENABLE_TRACING", "true"); | ||
| ApiTracer tracer = factory.newTracer(parent, spanName, OperationType.Unary); | ||
| assertThat(tracer).isInstanceOf(TracingTracer.class); | ||
| } | ||
|
|
||
| @Test | ||
| void testNewTracer_disabled() { | ||
| System.setProperty("GOOGLE_CLOUD_ENABLE_TRACING", "false"); | ||
| ApiTracer tracer = factory.newTracer(parent, spanName, OperationType.Unary); | ||
| assertThat(tracer).isSameInstanceAs(BaseApiTracer.getInstance()); | ||
| } | ||
|
|
||
| @Test | ||
| void testNewTracer_defaultDisabled() { | ||
| ApiTracer tracer = factory.newTracer(parent, spanName, OperationType.Unary); | ||
| assertThat(tracer).isSameInstanceAs(BaseApiTracer.getInstance()); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
tracingRecorderfield isprotectedand mutable. Since it's initialized in the constructor and not expected to be changed by subclasses, it should beprivate finalto ensure immutability and proper encapsulation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blakeli0 https://github.com/googleapis/sdk-platform-java/pull/2403/files#diff-fdc1dfb7a2b23501ab66d8e37f0aedc5ca87489d845479734f583773bab0a51a shows that the metrics counterpart also has the recorder as
protected. Do you know if we intend to have these classes extended at some point? I imagine a new metrics sdk may require a sub class.