Repository navigation
feat: add o11y gRPC tracing - #9267
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates OpenTelemetry tracing into API calls within google-gax. It updates createApiCall to wrap invocations with traceAttempt when telemetry is enabled, captures static and dynamic trace contexts, and propagates the internal method name via constructSettings. Additionally, traceAttempt is refactored to synchronously handle both synchronous results and Promises. The feedback highlights two important issues: first, checking result instanceof Promise is fragile and fails to correctly track the lifetime of streaming calls (which return streams rather than Promises); second, the unit tests use a synchronous callback mock that masks this premature span termination. It is recommended to check for thenables and streams to properly manage span lifetimes, and to update the tests to invoke callbacks asynchronously.
fa84a3f to
0706fc7
Compare
d231ce3 to
6ae7e02
Compare
6ae7e02 to
57d1e9a
Compare
6ed7d57 to
98c43f2
Compare
98c43f2 to
5691da9
Compare
add101e to
d7b3c8e
Compare
16cfa1e to
4a51201
Compare
|
/gemini review |
1405674 to
ae927fe
Compare
Ty for the comment! I updated the logic in the stack, but I removed the backstop parts. PR#9334 has the fix instead. The TLDR is that we never actually verified that REST calls were complete. |
5518beb to
f67243e
Compare
f67243e to
b604bf2
Compare
b604bf2 to
5bd9df0
Compare
5bd9df0 to
49458c5
Compare
49458c5 to
d6255ba
Compare
Wire TracerHelper.traceCall into createApiCall so gRPC calls emit spans when telemetry tracing is enabled. Covers unary, streaming, and callback-style calls, passing the isStreamingCall flag and the maxDurationMs backstop, and keeps the _fallback parameter type intact. Adds unit tests for the createApiCall tracing branch, stream retries, listener cleanup, and premature span closure. Squashed from 42 commits (24 of which were stale duplicates of shivaneep-o11y-tracer-helper-updates work) to restore linear history across the stack. Content is identical to the previous branch tip.
The staticArgs block started its optional chain at internalTelemetryInfo, leaving otherArgs itself unguarded, while internalMethodName a few lines below already used settings.otherArgs?.* This is not currently reachable: checkTelemetryEnabled(settings) guarantees otherArgs is defined before the tracing branch runs. It is also invisible to the compiler, since CallSettings declares otherArgs as required (CallOptions declares it optional), so tsc accepts the unguarded access. That combination means a refactor of the gating would surface this as a runtime TypeError with no compile-time warning. No behavior change.
traceCall now wraps the user's callback for stream calls as well, so the comment describing it as non-streaming only no longer holds. The tracedCallback ?? callback fallback is unchanged and still correct.
d6255ba to
1b77f4e
Compare
🤖 I have created a release *beep* *boop* --- <details><summary>gapic-generator: 5.4.0</summary> ## [5.4.0](gapic-generator-v5.3.0...gapic-generator-v5.4.0) (2026-09-22) ### Features * **o11y:** Wire enable_telemetry_tracing through the generator CLI ([#9373](#9373)) ([3533155](3533155)) </details> <details><summary>google-gax: 6.5.0</summary> ## [6.5.0](google-gax-v6.4.0...google-gax-v6.5.0) (2026-09-22) ### Features * Add o11y gRPC tracing ([#9267](#9267)) ([ff39233](ff39233)) * **gax:** Report response status codes on traced calls ([#9344](#9344)) ([800322d](800322d)) * **o11y:** Let callers enable tracing with env var ([#9377](#9377)) ([ed9d279](ed9d279)) * Pass through fallback parameter for HTTP calls ([#9277](#9277)) ([653de60](653de60)) ### Bug Fixes * **gax:** Detect aborts and timeouts by error name ([6ce394b](6ce394b)) * **gax:** Enforce the call deadline on the REST transport ([#9334](#9334)) ([ddafe50](ddafe50)) * **gax:** Map REST fallback transport errors to gRPC status codes ([be36fd9](be36fd9)) * **gax:** Report transport failures as UNAVAILABLE, as gRPC does ([db76247](db76247)) </details> <details><summary>admanager: 0.14.0</summary> ## [0.14.0](admanager-v0.13.0...admanager-v0.14.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>data: 7.2.0</summary> ## [7.2.0](data-v7.1.0...data-v7.2.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>chat: 0.32.0</summary> ## [0.32.0](chat-v0.31.0...chat-v0.32.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>api-gateway: 5.3.0</summary> ## [5.3.0](api-gateway-v5.2.0...api-gateway-v5.3.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>backupdr: 0.12.0</summary> ## [0.12.0](backupdr-v0.11.0...backupdr-v0.12.0) (2026-09-22) ### Features * **google/cloud/backupdr/v1beta:** Add google-cloud-backupdr ([#9372](#9372)) ([c07e77e](c07e77e)) </details> <details><summary>compute: 7.5.0</summary> ## [7.5.0](compute-v7.4.0...compute-v7.5.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>devicestreaming: 0.5.0</summary> ## [0.5.0](devicestreaming-v0.4.0...devicestreaming-v0.5.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>discoveryengine: 3.3.0</summary> ## [3.3.0](discoveryengine-v3.2.0...discoveryengine-v3.3.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>networkservices: 0.17.0</summary> ## [0.17.0](networkservices-v0.16.0...networkservices-v0.17.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>parametermanager: 0.8.0</summary> ## [0.8.0](parametermanager-v0.7.0...parametermanager-v0.8.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>solar: 0.7.0</summary> ## [0.7.0](solar-v0.6.0...solar-v0.7.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </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>
🤖 I have created a release *beep* *boop* --- <details><summary>gapic-generator: 5.4.0</summary> ## [5.4.0](gapic-generator-v5.3.0...gapic-generator-v5.4.0) (2026-09-22) ### Features * **o11y:** Wire enable_telemetry_tracing through the generator CLI ([#9373](#9373)) ([3533155](3533155)) </details> <details><summary>google-gax: 6.5.0</summary> ## [6.5.0](google-gax-v6.4.0...google-gax-v6.5.0) (2026-09-22) ### Features * Add o11y gRPC tracing ([#9267](#9267)) ([ff39233](ff39233)) * **gax:** Report response status codes on traced calls ([#9344](#9344)) ([800322d](800322d)) * **o11y:** Let callers enable tracing with env var ([#9377](#9377)) ([ed9d279](ed9d279)) * Pass through fallback parameter for HTTP calls ([#9277](#9277)) ([653de60](653de60)) ### Bug Fixes * **gax:** Detect aborts and timeouts by error name ([6ce394b](6ce394b)) * **gax:** Enforce the call deadline on the REST transport ([#9334](#9334)) ([ddafe50](ddafe50)) * **gax:** Map REST fallback transport errors to gRPC status codes ([be36fd9](be36fd9)) * **gax:** Report transport failures as UNAVAILABLE, as gRPC does ([db76247](db76247)) </details> <details><summary>admanager: 0.14.0</summary> ## [0.14.0](admanager-v0.13.0...admanager-v0.14.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>data: 7.2.0</summary> ## [7.2.0](data-v7.1.0...data-v7.2.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>chat: 0.32.0</summary> ## [0.32.0](chat-v0.31.0...chat-v0.32.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>api-gateway: 5.3.0</summary> ## [5.3.0](api-gateway-v5.2.0...api-gateway-v5.3.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>backupdr: 0.12.0</summary> ## [0.12.0](backupdr-v0.11.0...backupdr-v0.12.0) (2026-09-22) ### Features * **google/cloud/backupdr/v1beta:** Add google-cloud-backupdr ([#9372](#9372)) ([c07e77e](c07e77e)) </details> <details><summary>compute: 7.5.0</summary> ## [7.5.0](compute-v7.4.0...compute-v7.5.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>devicestreaming: 0.5.0</summary> ## [0.5.0](devicestreaming-v0.4.0...devicestreaming-v0.5.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>discoveryengine: 3.3.0</summary> ## [3.3.0](discoveryengine-v3.2.0...discoveryengine-v3.3.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>networkservices: 0.17.0</summary> ## [0.17.0](networkservices-v0.16.0...networkservices-v0.17.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>parametermanager: 0.8.0</summary> ## [0.8.0](parametermanager-v0.7.0...parametermanager-v0.8.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </details> <details><summary>solar: 0.7.0</summary> ## [0.7.0](solar-v0.6.0...solar-v0.7.0) (2026-09-22) ### Features * Update API sources and regenerate ([#9368](#9368)) ([57d0cfd](57d0cfd)) </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>
Call TracerHelper within createApiCall() and update unit tests accordingly