Skip to content

feat(gax): implement operation-level client request spans (T3) - #14549

Merged
jinseopkim0 merged 6 commits into
mainfrom
feat-t3-operation-spans
Oct 13, 2026
Merged

jinseopkim0 merged 6 commits into
mainfrom
feat-t3-operation-spans

Conversation

@jinseopkim0

@jinseopkim0 jinseopkim0 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR implements operation-level client request spans (T3) as the parent span for individual attempt spans (T4) in OpenTelemetryTracingTracer.

b/541322523

@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 an operation-level span (operationSpan) to the OpenTelemetryTracingTracer to represent the overall client request, wrapping the individual attempt spans. The attempt spans are now configured to link back to this operation span as their parent, rather than directly to the caller's parent context. Additionally, fallback mechanisms have been added to injectTraceContext and inScope to use the operation span when no active attempt span is present. The test suite has been updated to verify the creation, hierarchy, and lifecycle of this new operation span. There are no review comments, and I have no additional feedback to provide.

@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 an operation-level span (operationSpan) to the OpenTelemetryTracingTracer to act as a parent for individual attempt spans, establishing a clearer trace hierarchy. It also updates context injection, scope management, and lifecycle methods to handle both spans. The review feedback highlights a potential compilation error due to a missing endAttemptSpan method and suggests refactoring duplicate span-ending logic into a helper method. Additionally, it recommends ensuring distinct names for the operation and attempt spans when they would otherwise be identical, preventing confusion in tracing UIs.

@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 an operation-level span in OpenTelemetryTracingTracer to act as a parent for individual attempt spans. It updates trace context injection and scope management to fall back to the operation span when no attempt span is active. Additionally, it refactors span ending logic to set the status of failed spans to StatusCode.ERROR and updates corresponding unit and integration tests to verify the new span hierarchy and fallback behaviors. I have no feedback to provide as there are no review comments.

@jinseopkim0
jinseopkim0 force-pushed the feat-t3-operation-spans branch from 553b4fe to 23b22fc Compare October 5, 2026 17:35
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@jinseopkim0
jinseopkim0 force-pushed the feat-t3-operation-spans branch from 922962c to 018b3d8 Compare October 5, 2026 17: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 an operation-level span (operationSpan) in OpenTelemetryTracingTracer to act as a parent for individual attempt spans, aligning the tracing structure with overall logical operations. It updates trace context injection, scope management, and span lifecycle methods to handle this new hierarchy, and updates the corresponding unit and integration tests to verify the parent-child relationships and span counts. There are no review comments, and I have no feedback to provide.

@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 an operation-level span in OpenTelemetryTracingTracer to act as a parent for individual attempt spans, ensuring proper hierarchical tracing of client requests and retries under a single operation context. It also updates the trace context injection, scope management, and lifecycle of these spans, alongside corresponding unit and integration tests. The review feedback suggests improving code readability in OpenTelemetryTracingTracerTest.java by importing io.opentelemetry.api.trace.StatusCode and using it directly instead of its fully qualified name.

@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 an operation-level span in OpenTelemetryTracingTracer to serve as the parent for individual attempt spans, establishing a clearer tracing hierarchy. It also implements inScope() and updates injectTraceContext to fall back to the operation span when no attempt span is active. Feedback on these changes suggests avoiding marking superseded attempt spans as StatusCode.ERROR (by passing null instead of a CancellationException when ending them) to prevent artificially inflating error rate metrics in APM dashboards, along with updating the corresponding test verifications.

@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 an operation-level span (operationSpan) in OpenTelemetryTracingTracer to represent the overall client request, acting as a parent for individual attempt spans. It updates context injection, scope management, and lifecycle methods to handle both the operation and attempt spans correctly, ensuring they are closed and reported with the appropriate status. Corresponding unit and integration tests have been updated to verify this new hierarchical span structure. There are no review comments, so we have no additional feedback to provide.

@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 an operation-level span in OpenTelemetryTracingTracer to represent the overall client request, acting as a parent to individual attempt spans. It updates context injection and scope management to fall back to the operation span when no attempt span is active, and refactors span ending logic to handle both types of spans. Additionally, the corresponding unit and integration tests have been updated to verify the creation, hierarchy, and lifecycle of the new operation span. As there are no review comments, I have no feedback to provide.

@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 an operation-level span representing the overall client request in OpenTelemetryTracingTracer, nesting the individual attempt spans under it. It also implements the inScope() method, updates injectTraceContext to fall back to the operation span when no attempt span is active, and refactors span ending logic to handle both span types. Corresponding unit and integration tests have been updated and added to verify this new span hierarchy and fallback behavior. As there are no review comments, no further feedback is provided.

@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 an operation-level span (T3) in OpenTelemetryTracingTracer to wrap individual attempt spans (T4). Attempt spans now link to this operation span as their parent, which in turn links to the caller's parent context. The changes also implement the inScope() method and update injectTraceContext() to fall back to the operation span when no attempt is active, ensuring trace context is not lost. Corresponding unit and integration tests have been updated and added to verify these new span hierarchies and fallback behaviors. There are no review comments, so no additional feedback is provided.

@jinseopkim0
jinseopkim0 force-pushed the feat-t3-client-request-spans branch from f5cb394 to 62ff915 Compare October 6, 2026 19:29
@jinseopkim0
jinseopkim0 force-pushed the feat-t3-operation-spans branch from 4b851ad to 5864347 Compare October 7, 2026 20:43
@jinseopkim0
jinseopkim0 marked this pull request as ready for review October 7, 2026 21:07
@jinseopkim0
jinseopkim0 requested a review from a team as a code owner October 7, 2026 21:07
@jinseopkim0
jinseopkim0 requested a review from blakeli0 October 7, 2026 21:07
@jinseopkim0
jinseopkim0 force-pushed the feat-t3-client-request-spans branch 2 times, most recently from 0ce3d06 to 764beec Compare October 8, 2026 16:08
@jinseopkim0
jinseopkim0 force-pushed the feat-t3-operation-spans branch from 5864347 to ef62122 Compare October 8, 2026 20:09
Base automatically changed from feat-t3-client-request-spans to main October 9, 2026 16:18
This PR implements operation-level client request spans (T3) as the parent span for individual attempt spans (T4) in OpenTelemetryTracingTracer.
@jinseopkim0
jinseopkim0 force-pushed the feat-t3-operation-spans branch from 2f08818 to a4ca00b Compare October 12, 2026 14:56
@jinseopkim0
jinseopkim0 requested a review from blakeli0 October 12, 2026 15:04
@jinseopkim0
jinseopkim0 enabled auto-merge (squash) October 12, 2026 21:46
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

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

@jinseopkim0
jinseopkim0 merged commit 275063b into main Oct 13, 2026
299 of 303 checks passed
@jinseopkim0
jinseopkim0 deleted the feat-t3-operation-spans branch October 13, 2026 18:01
blakeli0 pushed a commit that referenced this pull request Oct 17, 2026
…n ITOtelTracing (#14673)

Update `testTracing_retry_grpc_linkedToParentContext` and
`testTracing_retry_httpjson_linkedToParentContext` in `ITOtelTracing` to
account for the operation-level span introduced in #14549 and wait for
asynchronous span completion using `waitForSpans`.

b/541322523
jinseopkim0 pushed a commit that referenced this pull request Oct 23, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>1.94.0</summary>

##
[1.94.0](v1.93.0...v1.94.0)
(2026-10-22)


### Features

* **auth:** request certificate-bound tokens for agent identities by
([01eaba1](01eaba1))
* **bigquery-jdbc:** Add clearcut telemetry client
([#14607](#14607))
([c702438](c702438))
* **bigquery-jdbc:** expose QueryStatistics for jobless queries
([#14596](#14596))
([15f472c](15f472c))
* **bigquery:** expose QueryStatistics from TableResult
([#14588](#14588))
([40b2b1a](40b2b1a))
* **bigtable:** add per-method session diversion configuration
([#14681](#14681))
([042dd3e](042dd3e))
* **bigtable:** support SessionCheckAndMutateRow on the session client
([#14565](#14565))
([86de9c1](86de9c1))
* **bigtable:** support SessionReadModifyWriteRow on the session client
([#14585](#14585))
([8e653b2](8e653b2))
* **firestore:** DML
([#14703](#14703))
([11bc071](11bc071))
* **gax:** implement operation-level client request spans (T3)
([#14549](#14549))
([275063b](275063b))
* **gax:** link attempt spans to parent context and clean up on
operation completion
([#14459](#14459))
([0c481bd](0c481bd))
* **gax:** standardize mapping terminal resumable upload exceptions to
ApiException
([#14624](#14624))
([d4961f0](d4961f0))
* **google/devicesandservices/health/v4beta:** add health v4beta
([#14600](#14600))
([95f863c](95f863c))
* **google/shopping/merchant/reviews/v1:** add shopping-merchant-reviews
([#14724](#14724))
([13310c7](13310c7))
* include writerId as part of trace id
([#13488](#13488))
([ffa8063](ffa8063))
* log actionable errors on operation failure in LoggingTracer
([#14460](#14460))
([27559f4](27559f4))
* populate client_stats in AppendRowsRequest
([#14614](#14614))
([a7a0098](a7a0098))
* **spanner:** add option to create GcpFallbackChannel per channel
instead of per pool
([#14501](#14501))
([74f7591](74f7591))


### Bug Fixes

* **api-common:** validate path template variables against dot segments
([#14641](#14641))
([4ad59e2](4ad59e2))
* **auth:** fix serialization gaps in DownscopedCredentials and
UrlIdentityPoolSubjectTokenSupplier
([#14341](#14341))
([a3e3324](a3e3324))
* **bigquery-jdbc:** ensure JDBC uses PQC-compliant algorithm by default
([#14560](#14560))
([b0ffe3d](b0ffe3d))
* **bigquery-jdbc:** fix Exception handling
([#14566](#14566))
([3e7a206](3e7a206))
* **bigquery-jdbc:** fix missing logger instances
([#14733](#14733))
([0e822dc](0e822dc))
* **bigquery-jdbc:** fix pqc working in proxy env
([#14599](#14599))
([ceb45b4](ceb45b4))
* **bigquery-jdbc:** format nested ARRAY fields as valid JSON in
Struct.toString()
([#14720](#14720))
([bc0126a](bc0126a))
* **bigquery-jdbc:** format TIMESTAMP as UTC in getString and add
multi-zone TIMESTAMP(12) tests
([#14666](#14666))
([e666612](e666612))
* **bigquery-jdbc:** honor `Calendar` timezone and prevent
`ClassCastException` in ResultSet temporal getters
([#14657](#14657))
([7dd2b37](7dd2b37))
* **bigquery-jdbc:** limit Storage Read API Arrow batch queue to 32
batches
([#14709](#14709))
([d339c41](d339c41))
* **bigquery-jdbc:** normalize `setTime` from Calendar zone to JVM zone
([#14660](#14660))
([54d2bc6](54d2bc6))
* **bigquery-jdbc:** poll the JSON reference queue and release processed
finalizers
([#14719](#14719))
([1b7d00d](1b7d00d))
* **bigquery-jdbc:** preserve `Timestamp` instant in `PreparedStatement`
and `CallableStatement` Calendar overloads
([#14640](#14640))
([3b02a44](3b02a44))
* **bigquery-jdbc:** preserve the instant on the TIMESTAMP write path
and bind LocalDateTime as STRING
([#14647](#14647))
([2106e26](2106e26))
* **bigquery-jdbc:** stop per-ResultSet logger registration leak
([#14718](#14718))
([e83c768](e83c768))
* **bigquery-jdbc:** stop producer and release resources on
ResultSet.close
([#14712](#14712))
([6b99452](6b99452))
* **bigquery:** fix invalid mappings in domain models
([#14646](#14646))
([17048ed](17048ed))
* **bigquery:** remove duplicate google-cloud-storage dependency
([#14586](#14586))
([ab6173e](ab6173e))
* **datastore:** allow any gRPC TransportChannelProvider in
DatastoreOptions
([#14478](#14478))
([d9a8db5](d9a8db5))
* **datastore:** update emulator zip checksum for 2.3.1
([#14592](#14592))
([fb73ed5](fb73ed5))
* **deps:** update dependency
com.google.api-client:google-api-client-bom to v2.9.2
([#14725](#14725))
([1ffa467](1ffa467))
* **gax-httpjson:** gracefully handle error details with unrecognized
types
([#14612](#14612))
([7295640](7295640))
* revise health metrics inflightBytes to become inflightBytesMax
([#14613](#14613))
([44a12ef](44a12ef))
* **showcase:** update parent context retry tests for operation span in
ITOtelTracing
([#14673](#14673))
([312b5ea](312b5ea))
* **spanner:** increase max inbound message size from 256MB to 300MB
([#14551](#14551))
([70c7439](70c7439))
* **spanner:** increase max inbound message size from 256MB to 300MB as
([70c7439](70c7439))
* **spanner:** prevent stream leaks and race conditions on result set
close
([#14665](#14665))
([013b49b](013b49b))
* **spanner:** support autoscaling config, edition, and positive
capacity in cloud instance actions
([#14574](#14574))
([004f0fd](004f0fd))


### Performance Improvements

* **bigquery:** defer blocking jobs.get RPC in QueryPageFetcher until
getNextPage()
([#14650](#14650))
([6183b63](6183b63))


### Dependencies

* Upgrade jackson-bom to v2.22.4
([#14701](#14701))
([09ce4c5](09ce4c5))


### Documentation

* **auth:** clarify quota project behavior on ImpersonatedCredentials
([#14597](#14597))
([4e5a0d0](4e5a0d0))
* **pubsub:** Create a Cloud Pub/Sub sample for publishing with hedging
([#14623](#14623))
([9de611f](9de611f))
* **pubsub:** regenerate README.md sample table
([#14643](#14643))
([5394618](5394618)),
refs
[#14543](#14543)
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
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