Skip to content

fix(google-api-core): align OpenTelemetry span names, kinds, and T3 endpoint attributes with spec - #18866

Merged
chalmerlowe merged 1 commit into
mainfrom
fix/otel-test-plan-alignment-2
Oct 28, 2026
Merged

chalmerlowe merged 1 commit into
mainfrom
fix/otel-test-plan-alignment-2

Conversation

@chalmerlowe

Copy link
Copy Markdown
Contributor

Problem

Several OpenTelemetry span fields did not match the Cloud SDK tracing specification:

  1. HTTP attempt (Tier 4) span names: Only recorded the HTTP verb (such as POST) instead of combining the verb and the URL template.
  2. Client method (Tier 3) span kind: Used CLIENT instead of INTERNAL. Tier 3 spans track the overall SDK method call, while Tier 4 spans track the outbound network attempts (CLIENT).
  3. Client method (Tier 3) endpoint attributes: Did not include url.domain (or server.address and server.port when configured in ClientOptions).

Solution

  • _observability.py: Updated _build_http_span_attributes to format the span name as {method} {url_template} (for example, POST /v1beta1/echo:echo).
    • Falls back to {method} when url_template is not provided.
  • method.py: Updated _GapicCallable.__init__ to:
    • Set the Tier 3 span kind to SpanKind.INTERNAL.
    • Merge _extract_endpoint_attributes(client_options) into the Tier 3 span attributes so url.domain is always recorded.
  • Tests and Matrix:

Notes for Reviewers

  • Endpoint attributes are extracted once when the method wrapper is initialized, adding no extra work during individual RPC calls.
  • Populating server.address and server.port from default transport hosts (when client_options.api_endpoint is not set by the caller) will be handled in a follow-up PR.

@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 updates OpenTelemetry tracing in google-api-core by changing the span kind of API method wrappers from CLIENT to INTERNAL and incorporating endpoint attributes (such as url.domain, server.address, and server.port) from client_options into these spans. Additionally, HTTP span names are updated to include the URL template (e.g., "POST /v1/echo"). Tests and the telemetry requirements matrix have been updated accordingly. There are no review comments, and I have no feedback to provide.

@chalmerlowe
chalmerlowe force-pushed the test/centralize-monorepo-core-sync-check branch from dbb6d01 to 1f69e89 Compare October 27, 2026 20:34
Base automatically changed from test/centralize-monorepo-core-sync-check to main October 27, 2026 22:06
@chalmerlowe
chalmerlowe force-pushed the fix/otel-test-plan-alignment-2 branch from c32dfd6 to 628ecb8 Compare October 27, 2026 23:02
@chalmerlowe
chalmerlowe force-pushed the fix/otel-test-plan-alignment-2 branch from 628ecb8 to d292a3a Compare October 28, 2026 09:00
@chalmerlowe
chalmerlowe requested review from a team as code owners October 28, 2026 09:00
@chalmerlowe
chalmerlowe requested review from sycai and removed request for a team October 28, 2026 09:01
@chalmerlowe
chalmerlowe changed the base branch from main to test/ignore-pytest-asyncio-loop-scope-warning October 28, 2026 09:01
@chalmerlowe
chalmerlowe changed the base branch from test/ignore-pytest-asyncio-loop-scope-warning to main October 28, 2026 21:03
@chalmerlowe
chalmerlowe force-pushed the fix/otel-test-plan-alignment-2 branch from d292a3a to c014818 Compare October 28, 2026 21:03
@chalmerlowe
chalmerlowe merged commit 2a10196 into main Oct 28, 2026
190 checks passed
@chalmerlowe
chalmerlowe deleted the fix/otel-test-plan-alignment-2 branch October 28, 2026 22:08
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.

2 participants