feat(gax): report response status codes on traced calls - #9344
Draft
shivanee-p wants to merge 1 commit into
Draft
shivanee-p wants to merge 1 commit into
shivanee-p wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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
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
force-pushed
the
shivaneep-o11y-status-code
branch
from
September 15, 2026 21:13
6dfbcfb to
20ab67b
Compare
shivanee-p
marked this pull request as draft
September 16, 2026 21:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pass through the status code to spans.
rpc.response.status_codeholds the gRPC status name on both transports, since gax resolves it everywhere.grpc.response.status_codemirrors it on gRPC spans, andhttp.response.status_codecarries 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 owngcp.method.typeand 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.