feat: add o11y gRPC tracing - #9267
shivanee-p wants to merge 3 commits into
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 |
2f47ead to
f54aaa4
Compare
c428d77 to
9ded6a0
Compare
quirogas
left a comment
There was a problem hiding this comment.
Thanks for wiring traceCall, the callback wrapper, and getTracingBackstopMs through createApiCall, along with the new unit tests in apiCallable.ts. One small nit inline.
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
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.
5bd9df0 to
49458c5
Compare
Call TracerHelper within createApiCall() and update unit tests accordingly