Skip to content

feat(gax): emit T4 attempt spans - #9496

Open
shivanee-p wants to merge 13 commits into
mainfrom
shivaneep-o11y-t4-headers
Open

shivanee-p wants to merge 13 commits into
mainfrom
shivaneep-o11y-t4-headers

Conversation

@shivanee-p

@shivanee-p shivanee-p commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Emits OpenTelemetry tracing spans per-attempt transport spans (SpanKind.CLIENT) directly from google-gax for both gRPC and HTTP/REST fallback calls

Key Changes:

  • Added traceAttempt() and AttemptTraceContext to wrap each individual transport attempt (<apiName>/<methodName>, SpanKind.CLIENT), parented to the enclosing T3 client call span (<ClientName>.<MethodName>, SpanKind.INTERNAL)
  • Populated T4 span attributes: gcp.client.service/rpc.system, rpc.method/http.request.method, url.domain, server.address, server.port, gcp.grpc.resend_count/http.request.resend_count, error.type, span error status, and exception events on attempt failures
  • Propagated servicePath / apiEndpoint and port from GrpcClient options into constructSettings otherArgs so static trace context resolves custom endpoints and ports
  • Added unit tests covering traceAttempt, T3/T4 parent-child hierarchies across unary, retries, and streaming calls, HTTP verb resolution, and transport-specific status code attributes

@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 OpenTelemetry trace context propagation into gRPC and HTTP/REST metadata within the gax package, introducing an isMetadata utility and a comprehensive test suite. The review feedback points out that plain object metadata should be cloned before injecting the active span context to prevent unintended mutations and trace context leakage.

Comment thread core/packages/gax/src/normalCalls/timeout.ts Outdated
@shivanee-p
shivanee-p force-pushed the shivaneep-o11y-t4-headers branch from c711b36 to 4bdc143 Compare October 1, 2026 20:36
@shivanee-p
shivanee-p marked this pull request as ready for review October 1, 2026 20:36
@shivanee-p
shivanee-p requested a review from a team as a code owner October 1, 2026 20:36
@github-actions
github-actions Bot requested a review from danieljbruce October 1, 2026 20:36
@quirogas
quirogas requested review from quirogas and removed request for danieljbruce October 1, 2026 20:44
@quirogas
quirogas marked this pull request as draft October 1, 2026 20:51
@shivanee-p
shivanee-p force-pushed the shivaneep-o11y-t4-headers branch from 7e54208 to 396dcd0 Compare October 2, 2026 00:56
@shivanee-p shivanee-p changed the title feat(gax): inject active OpenTelemetry span context into header metadata feat(gax): emit T4 attempt spans Oct 2, 2026
@shivanee-p

Copy link
Copy Markdown
Contributor Author

/gemini review

@shivanee-p
shivanee-p marked this pull request as ready for review October 2, 2026 01:59
@github-actions
github-actions Bot requested a review from bshaffer October 2, 2026 02:00
@shivanee-p
shivanee-p removed request for a team and bshaffer October 2, 2026 02:00

@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 Tier 4 (T4) per-attempt tracing spans (OpenTelemetry CLIENT spans) parented under the T3 client request spans in google-gax. It adds traceAttempt in TracerHelper.ts to manage individual RPC transport attempts, captures service path and port configurations in both gRPC and fallback clients, and updates unit tests to verify the new span relationships and attributes. Feedback on the changes highlights a critical issue in createApiCall.ts where mutating the outer func parameter inside invokeCall causes a memory leak and call stack growth across multiple API calls; a fix is suggested to wrap currentApiCaller instead.

Comment thread core/packages/gax/src/createApiCall.ts
@github-actions
github-actions Bot requested a review from danieljbruce October 2, 2026 05:13

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.

1 participant