Skip to content

feat(core): add request hook to enrich T4 network spans with GCP resource attributes (E) - #18272

Draft
chalmerlowe wants to merge 1 commit into
feat/otel-tracing-t3-method-spansfrom
feat/otel-tracing-t4-resource-attributes
Draft

feat(core): add request hook to enrich T4 network spans with GCP resource attributes (E)#18272
chalmerlowe wants to merge 1 commit into
feat/otel-tracing-t3-method-spansfrom
feat/otel-tracing-t4-resource-attributes

Conversation

@chalmerlowe

@chalmerlowe chalmerlowe commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR implements OpenTelemetry tracing in google-api-core:

  • Adds an OpenTelemetry client request_hook to otel_grpc.client_interceptor and otel_grpc.aio_client_interceptors.
  • Dynamically extracts semantic Google Cloud resource attributes from gRPC request objects:
    • gcp.resource.name
    • gcp.resource.parent
    • gcp.project_id (parsed from standard AIP-122 resource names and parents)
  • Injects these attributes directly into the active wire-level span.
  • Adds comprehensive unit tests validating extraction from requests and attachment to spans.

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.

@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 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
chalmerlowe force-pushed the feat/otel-tracing-t4-resource-attributes branch from a7be0e4 to 9efe757 Compare September 3, 2026 14:49
@chalmerlowe
chalmerlowe changed the base branch from feat/otel-tracing-transport-logic to feat/otel-tracing-t3-method-spans September 3, 2026 14:50
@chalmerlowe chalmerlowe added this to the [o11y] Tracing milestone Sep 3, 2026
@chalmerlowe chalmerlowe changed the title feat(core): add request hook to inject GCP resource and project attributes into OpenTelemetry spans feat(core): add OpenTelemetry T4 span wrapping (E) Sep 3, 2026
@chalmerlowe chalmerlowe self-assigned this Sep 3, 2026
@chalmerlowe chalmerlowe changed the title feat(core): add OpenTelemetry T4 span wrapping (E) feat(core): add request hook to enrich spans with GCP resource attributes (E) Sep 3, 2026
@chalmerlowe
chalmerlowe force-pushed the feat/otel-tracing-t4-resource-attributes branch from 9efe757 to 40071ff Compare September 3, 2026 15:25
@chalmerlowe
chalmerlowe force-pushed the feat/otel-tracing-t4-resource-attributes branch from 40071ff to 8c9d21a Compare September 4, 2026 09:04
@chalmerlowe
chalmerlowe force-pushed the feat/otel-tracing-t4-resource-attributes branch from 8c9d21a to 558f8fd Compare September 4, 2026 09:13
@chalmerlowe chalmerlowe changed the title feat(core): add request hook to enrich spans with GCP resource attributes (E) feat(core): add request hook to enrich T4 network spans with GCP resource attributes (E) Sep 4, 2026
@chalmerlowe
chalmerlowe force-pushed the feat/otel-tracing-t4-resource-attributes branch from 558f8fd to a6f3b3a Compare September 4, 2026 11:49
@chalmerlowe
chalmerlowe force-pushed the feat/otel-tracing-t4-resource-attributes branch from a6f3b3a to 7e1e498 Compare September 4, 2026 14:55
@chalmerlowe
chalmerlowe force-pushed the feat/otel-tracing-t4-resource-attributes branch from 7e1e498 to 131a80a Compare September 4, 2026 17:41
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