Skip to content

fix(gax): make CompositeTracer completion-callback scoping best-effort - #15121

Open
jinseopkim0 wants to merge 3 commits into
mainfrom
fix-composite-tracer-callback-scope-errors
Open

jinseopkim0 wants to merge 3 commits into
mainfrom
fix-composite-tracer-callback-scope-errors

Conversation

@jinseopkim0

@jinseopkim0 jinseopkim0 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Makes CompositeTracer completion-callback scoping best-effort via dispatchCompletionCallback, logging scope enter/close failures at FINE so child callbacks and RPC future completion are not disrupted.

b/499388983

@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 updates CompositeTracer to handle exceptions thrown when entering or closing tracer scopes during completion callbacks, preventing RPC futures from hanging or skipping remaining callbacks. It also introduces comprehensive tests to verify this behavior. The review feedback highlights two main points: first, a suggestion to reorder assertions in the test to prevent potential flakiness from asynchronous execution; second, a concern that using a static JVM-wide AtomicBoolean to suppress duplicate warning logs could inadvertently hide critical tracer failures in other parts of the application.

@jinseopkim0
jinseopkim0 marked this pull request as ready for review November 20, 2026 23:04
@jinseopkim0
jinseopkim0 requested a review from a team as a code owner November 20, 2026 23:04
@jinseopkim0
jinseopkim0 requested a review from lqiu96 November 23, 2026 19:55
@jinseopkim0 jinseopkim0 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 1, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 1, 2026
*/
@NullMarked
@InternalApi
class CompositeTracer extends BaseApiTracer {

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.

General question: Do you know if this also works for streaming? I don't recall the details but IIUC BasicRetryingFuture is for unary, but I don't recall how streaming flows

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.

Yes, it works for all streaming types as well:

  1. Server streaming actually uses BasicRetryingFuture (via RetryingServerStreamingCallable) for retry attempt callbacks, and TracedResponseObserver for operationSucceeded / operationFailed / operationCancelled.
  2. Client and bidi streaming don't use BasicRetryingFuture, but both invoke tracer.operation*() inside TracedResponseObserver right before calling innerObserver.onComplete() / onError(). With best-effort scoping in CompositeTracer, a scope failure can't prevent the user's stream observer from receiving terminal completion/error callbacks.

@jinseopkim0
jinseopkim0 requested a review from lqiu96 December 4, 2026 21:20
@jinseopkim0
jinseopkim0 enabled auto-merge (squash) December 4, 2026 21:20
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 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%)

See analysis details on SonarQube Cloud

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.

3 participants