Skip to content

feat(gax): report response status codes on traced calls - #9344

Draft
shivanee-p wants to merge 1 commit into
shivaneep-o11y-http-tracingfrom
shivaneep-o11y-status-code
Draft

shivanee-p wants to merge 1 commit into
shivaneep-o11y-http-tracingfrom
shivaneep-o11y-status-code

Conversation

@shivanee-p

Copy link
Copy Markdown
Contributor

Pass through the status code to spans. rpc.response.status_code holds the gRPC status name on both transports, since gax resolves it everywhere. grpc.response.status_code mirrors it on gRPC spans, and http.response.status_code carries the received HTTP status on fallback spans.

The HTTP status is plumbed from the fetch response through decodeResponse onto GoogleError.httpStatusCode, and is absent when no response arrived at all, such as an expired deadline.

Success is inferred rather than observed. The unary path never surfaces a status object to gax, so a call that reported no error is recorded as OK, and 200 on the fallback.

Adds OtelHarness.assertResponseStatus, which derives the expected attribute shape from the span's own gcp.method.type and asserts both the presence of the attribute that applies and the absence of the one that does not, so a test cannot assert a combination the tracer should never produce.

@shivanee-p
shivanee-p requested a review from a team as a code owner September 15, 2026 21:10

@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 enhances error reporting and telemetry in the REST fallback transport by capturing and recording the actual HTTP response status code. It introduces an 'httpStatusCode' property to 'GoogleError' and updates the OpenTelemetry tracing helper ('TracerHelper') to extract and attach 'rpc.response.status_code', 'grpc.response.status_code', and 'http.response.status_code' attributes to spans. Comprehensive unit tests have also been added to verify these changes. I have no further feedback to provide as the implementation is robust and well-tested.

@shivanee-p
shivanee-p added this pull request to stack #9345 September 15, 2026 21:12
Spans now carry the status of the call they measure. rpc.response.status_code holds the gRPC status name on both transports, since that is the one status gax resolves everywhere and the only value comparable across them. grpc.response.status_code mirrors it on gRPC spans, and http.response.status_code carries the received HTTP status on fallback spans.

The HTTP status could not simply be derived from the gRPC code: rpcCodeFromHttpStatusCode collapses whole ranges, so the received status is unrecoverable from the mapping. It is now plumbed from the fetch response through decodeResponse onto GoogleError.httpStatusCode, and is absent when no response arrived at all, such as an expired deadline.

Success is inferred rather than observed. The unary path never surfaces a status object to gax, so a call that reported no error is recorded as OK, and 200 on the fallback.

Adds OtelHarness.assertResponseStatus, which derives the expected attribute shape from the span's own gcp.method.type and asserts both the presence of the attribute that applies and the absence of the one that does not, so a test cannot assert a combination the tracer should never produce.
@shivanee-p
shivanee-p force-pushed the shivaneep-o11y-status-code branch from 6dfbcfb to 20ab67b Compare September 15, 2026 21:13
@shivanee-p
shivanee-p marked this pull request as draft September 16, 2026 21:14
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