-
Notifications
You must be signed in to change notification settings - Fork 70
chore: (do not merge) tracing and artifact name POC #4093
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
Closed
Closed
Changes from all commits
Commits
Show all changes
53 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 8a0f855
chore: add dummy tracing metric
diegomarquezp dc3ed42
chore: refine tracing IT
diegomarquezp 5287f82
feat: add composite api tracer
diegomarquezp ce2d85b
test: use global config for tracing
diegomarquezp d6341cc
chore: restore metrics it
diegomarquezp a9c70ab
chore: format
diegomarquezp 69a7fa4
Merge branch 'observability/tracing-noop' of https://github.com/googl…
diegomarquezp a6716b4
chore: format ii
diegomarquezp 99bfd5b
chore: generate libraries at Mon Jan 12 21:30:41 UTC 2026
cloud-java-bot 7b5709b
Merge branch 'observability/tracing-noop' of https://github.com/googl…
diegomarquezp 6259b86
fix: Create a single S2AChannelCredentials per application (#3989)
rmehta19 61c1671
feat: add org.json:json to third-party-dependencies pom (#4047)
chingor13 069bc77
build: Update macOS version in nightly workflow (#4048)
diegomarquezp f5f94d8
chore(deps): update upper bound dependencies file (#4052)
diegomarquezp 64685b5
deps: update google.http-client.version to 2.0.3 (#4054)
diegomarquezp 7869ed9
chore: update googleapis commit at Wed Dec 10 02:37:02 UTC 2025 (#4013)
cloud-java-bot 5218acb
chore(main): release 2.65.0 (#4058)
release-please[bot] 7686f7f
build: Skip clirr check for protobuf 4.x upgrade (#4061)
blakeli0 af882ca
docs: Update docs for GoogleCredentialsProvider#setScopesToApply (#4057)
blakeli0 7575f5c
chore(main): release 2.65.1-SNAPSHOT (#4060)
release-please[bot] 7d98fcc
build: Skip clirr check for downstream libraries (#4062)
blakeli0 24f7fc5
chore: Update protobuf runtime version to 4.33.4 in downstream checks…
blakeli0 cee4ad5
chore(main): release 2.65.1 (#4063)
release-please[bot] 7aa0ea5
chore: cleanup release-please config (#4002)
diegomarquezp 7f90d28
chore: generate libraries at Thu Jan 8 19:39:27 UTC 2026
cloud-java-bot d0b2eb3
chore: simplify implementation (no C3)
diegomarquezp ce9df43
Merge remote-tracking branch 'origin/main' into observability/tracing…
diegomarquezp b063a8d
chore: generate libraries at Wed Jan 21 20:06:59 UTC 2026
cloud-java-bot 5da1d58
Merge branch 'observability/tracing-noop' of https://github.com/googl…
diegomarquezp 8ffb32a
chore: adapt units in gax
diegomarquezp e3b2cda
chore: new option artifact-name for generator
diegomarquezp 92d56e7
chore: add artifact name property to ClientContext and StubSettings
diegomarquezp 5082240
chore: modify TracingTracerFactory
diegomarquezp e8d98b0
chore: remove initialization in client context
diegomarquezp 87a3f8c
Merge remote-tracking branch 'origin/main' into observability/tracing…
diegomarquezp 20461c1
chore: configure tracer factory in client context
diegomarquezp 40b74bd
chore: format
diegomarquezp d1967f7
chore: introduce span context
diegomarquezp f626d4b
chore: adjust compilation issues and format
diegomarquezp e9fe905
chore: add scope
diegomarquezp 09d1539
test: adjust goldens for pubsub
diegomarquezp a240c29
chore: suppress resource closed warning
diegomarquezp 2334254
feat: generate with artifact_name
diegomarquezp 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
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
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
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
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
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
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
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
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
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
96 changes: 96 additions & 0 deletions
96
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,96 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| * | ||
| * 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; | ||
| import io.opentelemetry.api.trace.Span; | ||
| import io.opentelemetry.api.trace.SpanBuilder; | ||
| import io.opentelemetry.api.trace.SpanKind; | ||
| import io.opentelemetry.api.trace.StatusCode; | ||
| import io.opentelemetry.api.trace.Tracer; | ||
| import io.opentelemetry.context.Scope; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * 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 Tracer tracer; | ||
|
|
||
| public OpenTelemetryTracingRecorder(OpenTelemetry openTelemetry) { | ||
| this.tracer = openTelemetry.getTracer("gax-java"); | ||
| } | ||
|
|
||
| @Override | ||
| @SuppressWarnings("MustBeClosedChecker") // Scope is closed later in the lifecycle | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| public SpanHandle startSpan(String name, Map<String, String> attributes) { | ||
| SpanBuilder spanBuilder = | ||
| tracer.spanBuilder(name).setSpanKind(SpanKind.CLIENT); // Mark as a network-facing call | ||
|
|
||
| if (attributes != null) { | ||
| attributes.forEach((k, v) -> spanBuilder.setAttribute(k, v)); | ||
| } | ||
|
|
||
| Span span = spanBuilder.startSpan(); | ||
| // makeCurrent() puts this span into the thread-local storage | ||
| Scope scope = span.makeCurrent(); | ||
|
|
||
| return new OtelSpanHandle(span, scope); | ||
| } | ||
|
|
||
| private static class OtelSpanHandle implements SpanHandle { | ||
| private final Span span; | ||
| private final Scope scope; | ||
|
|
||
| private OtelSpanHandle(Span span, Scope scope) { | ||
| this.span = span; | ||
| this.scope = scope; | ||
| } | ||
|
|
||
| @Override | ||
| public void end() { | ||
| scope.close(); // Remove from thread-local storage | ||
| span.end(); | ||
| } | ||
|
|
||
| @Override | ||
| public void recordError(Throwable error) { | ||
| span.recordException(error); | ||
| span.setStatus(StatusCode.ERROR); | ||
| } | ||
| } | ||
| } | ||
82 changes: 82 additions & 0 deletions
82
gax-java/gax/src/main/java/com/google/api/gax/tracing/OpenTelemetryTracingTracer.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,82 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| * | ||
| * 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 java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| @BetaApi | ||
| @InternalApi | ||
| public class OpenTelemetryTracingTracer implements ApiTracer { | ||
| private final TracingRecorder recorder; | ||
| private final Map<String, String> attributes; | ||
| private TracingRecorder.SpanHandle operationHandle; | ||
| private TracingRecorder.SpanHandle attemptHandle; | ||
|
|
||
| public OpenTelemetryTracingTracer(TracingRecorder recorder, String methodName) { | ||
| this.recorder = recorder; | ||
| this.attributes = new HashMap<>(); | ||
| this.attributes.put("method", methodName); | ||
|
|
||
| // Start the long-lived operation span | ||
| this.operationHandle = recorder.startSpan(methodName + "/operation", attributes); | ||
| } | ||
|
|
||
| @Override | ||
| public void attemptStarted(Object request, int attemptNumber) { | ||
| // Start the specific attempt span | ||
| this.attemptHandle = recorder.startSpan(this.attributes.get("method") + "/attempt", attributes); | ||
| } | ||
|
|
||
| @Override | ||
| public void attemptSucceeded() { | ||
| if (attemptHandle != null) { | ||
| attemptHandle.end(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void operationSucceeded() { | ||
| operationHandle.end(); | ||
| } | ||
|
|
||
| @Override | ||
| public void operationFailed(Throwable error) { | ||
| operationHandle.recordError(error); | ||
| operationHandle.end(); | ||
| } | ||
|
|
||
| public void addAttributes(Map<String, String> attributes) { | ||
| this.attributes.putAll(attributes); | ||
| } | ||
| } | ||
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 copyright year in the newly added code block is set to
2026. Please update this to the current year,2024, to maintain consistency with the project's copyright practices.