Skip to content

test(showcase): add GAPIC Showcase integration tests for OpenTelemetry T3 tracing - #14583

Open
jinseopkim0 wants to merge 1 commit into
mainfrom
test-showcase-t3-tracing
Open

jinseopkim0 wants to merge 1 commit into
mainfrom
test-showcase-t3-tracing

Conversation

@jinseopkim0

@jinseopkim0 jinseopkim0 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #15298 (fix-gax-client-timeout-attributes) to validate client-timeout T3 span attributes end-to-end.

This PR adds GAPIC Showcase integration tests for OpenTelemetry T3 tracing, covering:

  • F1.1–F1.8: Base T3 operation spans across HTTP/JSON and gRPC for success, server error, and client deadline exceeded failures.
  • F2.1–F2.4: T3/T4 parent-child span hierarchy and retry aggregation for retry success and retries exhausted scenarios.
  • F3.1–F3.2: OpenTelemetry M3 client request duration metrics correlation with T3 span exemplars.

b/588573053

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements client-level T3 tracing and M3 metrics exemplar correlation using OpenTelemetry in the GAX Java library, introducing a two-level span hierarchy (overall operation and individual attempts) managed thread-safely via ReentrantLock. It also adds comprehensive integration and unit tests to verify these tracing behaviors across HTTP and gRPC transports. A review comment identifies a potential NullPointerException in OpenTelemetryTracingTracer when comparing attemptSpanName to operationSpanName if the former is null, and suggests reversing the comparison to ensure safety.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from 95d6b8d to 0b9ef39 Compare October 5, 2026 17:23
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a two-level span hierarchy (T3 operation-level spans and T4 attempt-level child spans) in OpenTelemetryTracingTracer to support tracking of overall RPC operations and individual retry attempts. It also updates CompositeTracer to safely manage scopes and suppress exceptions during lifecycle notifications, and adds comprehensive integration and unit tests for tracing, hierarchy, and metrics exemplar correlation. The review feedback correctly identifies a potential IllegalArgumentException in CompositeTracer if an exception attempts to suppress itself, and suggests a robust check to prevent this.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from 0b9ef39 to 1b3a338 Compare October 5, 2026 17:28
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements client-level T3 tracing and M3 metrics exemplar correlation using OpenTelemetry in the Java SDK, adding comprehensive integration tests for tracing hierarchy, retry aggregation, and metrics exemplars. Key changes include refactoring OpenTelemetryTracingTracer to manage an overall operation span (T3) and link individual attempt spans (T4) as children, and updating CompositeTracer to handle scopes safely. Feedback on these changes suggests ending lingering attempt spans with a CancellationException instead of null when superseded by a retry to prevent misleading success metrics, and avoiding the suppression of tracing-internal exceptions on business errors in CompositeTracer to keep telemetry transparent and non-intrusive.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from 1b3a338 to 110f41c Compare October 5, 2026 17:31
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from 110f41c to b44fecd Compare October 5, 2026 17:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements client-level T3 tracing and M3 metrics exemplar correlation using OpenTelemetry. It updates CompositeTracer and OpenTelemetryTracingTracer to support parent operation spans and child attempt spans with thread-safe state management, and introduces comprehensive integration and unit tests. The review feedback suggests minor readability improvements by replacing redundant fully qualified class names with their simple imported names.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from b44fecd to cf898f1 Compare October 5, 2026 17:35
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces operation-level tracing (T3 spans) alongside attempt-level tracing (T4 spans) in OpenTelemetryTracingTracer, establishing a proper parent-child span hierarchy for retries and aggregating retry results onto the operation span. It adds thread-safe coordination using a ReentrantLock to manage attempt transitions and operation completion. Additionally, comprehensive integration and unit tests have been added to verify client-level T3 tracing, T3/T4 hierarchy, and exemplar correlation across both HTTP/JSON and gRPC transports. I have no further feedback to provide as there are no review comments to evaluate.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from cf898f1 to e3ca6a3 Compare October 5, 2026 17:40
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive client-level OpenTelemetry tracing (T3) and attempt-level tracing (T4) hierarchy, along with metrics exemplar correlation (M3) in GAX Java. It updates OpenTelemetryTracingTracer to manage an overall operation-level span (T3) that acts as the parent for individual attempt spans (T4), ensuring proper retry aggregation and thread-safe state transitions using a ReentrantLock. Additionally, CompositeTracer is updated to run lifecycle notifications within the active scope, and several new integration and unit tests are added to validate these features across both gRPC and HTTP/JSON transports. I have no feedback to provide as there are no review comments.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from e3ca6a3 to bd86844 Compare October 5, 2026 17:44
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a hierarchical span structure (T3 operation span and T4 attempt spans) for OpenTelemetry tracing in GAX, along with integration tests verifying tracing and metrics exemplar correlation. It also updates CompositeTracer to execute lifecycle operations within the tracer's scope. Feedback on CompositeTracer.java highlights that a RuntimeException thrown during scope.close() in runInScope could propagate and disrupt lifecycle notifications, and suggests a safer try-finally block to catch and ignore such exceptions.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from bd86844 to 5c6f2ac Compare October 5, 2026 17:47
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from 5c6f2ac to 1353598 Compare October 5, 2026 17:51
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces client-level T3/T4 span hierarchy and retry aggregation using OpenTelemetry in the GAX Java library. It implements an overall operation-level span (T3) that acts as a parent to individual attempt-level spans (T4), ensuring thread-safe coordination of spans and retry aggregation. Additionally, comprehensive integration and unit tests have been added to validate tracing behavior, metrics exemplar correlation, and span hierarchy across both gRPC and HTTP/JSON transports. I have no feedback to provide as there are no review comments to assess.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements hierarchical tracing and metrics exemplar correlation using OpenTelemetry. It introduces operation-level (T3) spans as parents to individual attempt (T4) spans, manages thread-safe span state with a ReentrantLock, and implements robust context propagation. Comprehensive integration and unit tests have been added to verify these tracing behaviors. The feedback suggests importing io.opentelemetry.context.Context directly rather than using its fully qualified name to improve code readability.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from 1353598 to cb7a885 Compare October 5, 2026 17:58
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces client-level T3 tracing and T4 attempt span hierarchy, along with metrics exemplar correlation using OpenTelemetry in GAX. Key changes include the creation of an operation-level span (T3) that acts as a parent to individual attempt spans (T4), thread-safe state management using a ReentrantLock in OpenTelemetryTracingTracer, and robust scope handling in CompositeTracer. Additionally, comprehensive integration and unit tests have been added to verify these behaviors. The feedback highlights an important improvement opportunity in CompositeTracer.java to ensure that child scopes are closed in reverse order (LIFO) and wrapped in try-catch blocks to prevent resource leaks if an exception is thrown during closure.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from cb7a885 to f9da41b Compare October 5, 2026 18:04
@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from 1253bdf to d400486 Compare November 20, 2026 23:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for certificate-bound tokens for agent identities, GKE credential bundle fallbacks, and actor tokens within ComputeEngineCredentials and IdentityPoolCredentials. It also enhances error parsing in IamUtils and adds caching mechanisms to avoid redundant certificate validation. The reviewer feedback suggests storing certificate chains in memory rather than keeping file paths to prevent race conditions during rotation. Additionally, the reviewer points out potential HTTP connection leaks in ComputeEngineCredentials when throwing exceptions on 404 error paths without disconnecting the response.

@jinseopkim0
jinseopkim0 changed the base branch from feat-t3-metrics-exemplars to main November 20, 2026 23:38
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces three new integration test files (ITOtelT3MetricsExemplar.java, ITOtelT3T4Hierarchy.java, and ITOtelT3Tracing.java) to validate OpenTelemetry tracing, metrics exemplar correlation, and span hierarchy/retry aggregation behaviors across HTTP/JSON and gRPC transports. The review feedback points out a bug in ITOtelT3Tracing.java where the expected http.url_template attribute value in an assertion is incorrect and should be updated to avoid test failure.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from d400486 to 5cfabd6 Compare November 20, 2026 23:56
@jinseopkim0
jinseopkim0 marked this pull request as ready for review November 20, 2026 23:59
@jinseopkim0
jinseopkim0 requested a review from a team as a code owner November 20, 2026 23:59
@jinseopkim0
jinseopkim0 requested a review from lqiu96 November 23, 2026 19:54
try (EchoClient client = EchoClient.create(stub)) {
client.echo(EchoRequest.newBuilder().setContent("exemplar-test-http").build());

List<SpanData> spans = waitAndCollectSpans(2);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq, why two spans here? and same for below, why 2/3 spans for each?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each RPC creates one outer operation span (T3) plus one child span per network attempt (T4):

  • 2 spans (in ITOtelT3MetricsExemplar): 1 T3 operation span + 1 T4 attempt span for a single-attempt RPC.
  • 3 spans (in ITOtelT3T4Hierarchy): 1 T3 operation span + 2 T4 attempt spans for a retried RPC (first attempt + retry).

We wait for all of them to export because the outer T3 span closes right after the inner T4 attempt span finishes.

@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from 5cfabd6 to 2478cec Compare December 1, 2026 15:15
@jinseopkim0
jinseopkim0 changed the base branch from main to fix-gax-client-timeout-attributes December 1, 2026 15:15
@jinseopkim0
jinseopkim0 added this pull request to stack #15324 December 1, 2026 15:17
@jinseopkim0
jinseopkim0 requested a review from lqiu96 December 1, 2026 15:28

@BeforeEach
void setUp() {
GlobalOpenTelemetry.resetForTest();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq, why does this test have GlobalOTel? Do we need this for the other ITs as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for the disabled-tracing tests (testTracingDisabled_*): registering our test SDK globally makes sure that even when tracing isn't configured on the client, we'd still catch any accidental spans if GAX ever fell back to the global OpenTelemetry instance.

The other ITs don't need it since they only test the enabled path where the SDK is passed explicitly.

Comment on lines +185 to +190
private List<SpanData> waitAndCollectSpans(int minSpans) {
Awaitility.await()
.atMost(Duration.ofSeconds(5))
.until(() -> spanExporter.getFinishedSpanItems().size() >= minSpans);
return spanExporter.getFinishedSpanItems();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in a follow up PR: I think I see waitAndCollectSpans() and potentially some other helpers that could be re-used across the additional ITs. Maybe it may be helpful for a central place for the OtelHelpers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Will follow-up with a separate PR.

@lqiu96 lqiu96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Tests look to pass. Added a few small comments

Base automatically changed from fix-gax-client-timeout-attributes to main December 1, 2026 20:29
@jinseopkim0
jinseopkim0 force-pushed the test-showcase-t3-tracing branch from 2478cec to 8588735 Compare December 1, 2026 20:29
@jinseopkim0
jinseopkim0 enabled stacked auto-merge (squash) December 1, 2026 20:30

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants