feat(core): add request hook to enrich spans with GCP resource attributes (E) - #18272
Draft
chalmerlowe wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces OpenTelemetry request hooks to extract and inject Google Cloud semantic and resource attributes (such as resource name, parent, and project ID) from gRPC request objects into OpenTelemetry spans. Specifically, it adds _extract_t4_attributes and _client_request_hook helper functions in _observability.py, registers the hook in the gRPC client interceptors, and includes comprehensive unit tests to verify this behavior. There are no review comments, so I have no feedback to provide.
chalmerlowe
force-pushed
the
feat/otel-tracing-t4-resource-attributes
branch
from
September 3, 2026 14:49
a7be0e4 to
9efe757
Compare
chalmerlowe
changed the base branch from
feat/otel-tracing-transport-logic
to
feat/otel-tracing-t3-method-spans
September 3, 2026 14:50
chalmerlowe
force-pushed
the
feat/otel-tracing-t4-resource-attributes
branch
from
September 3, 2026 15:25
9efe757 to
40071ff
Compare
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.
Summary
This PR implements Option A for OpenTelemetry tracing in
google-api-core:request_hooktootel_grpc.client_interceptorandotel_grpc.aio_client_interceptors.gcp.resource.namegcp.resource.parentgcp.project_id(parsed from standard AIP-122 resource names and parents)Why
Enriches raw gRPC transport spans with high-level Google Cloud resource context without requiring modifications to generated client methods or waiting for higher-level method decorators.
Verification
run_nox_docker.sh lint(Passed: ruff & flake8 clean)run_nox_docker.sh mypy(Passed: 119 files checked)run_nox_docker.sh unit-3.10(Passed: 18 passed)projects/callovianwith Secret Manager confirmedgcp.project_idandgcp.resource.parentare captured on emitted spans.