Skip to content

impl(v2): add client request spans to gax.Invoke - #503

Draft
westarle wants to merge 5 commits into
googleapis:mainfrom
westarle:feat/t3-traces-go
Draft

westarle wants to merge 5 commits into
googleapis:mainfrom
westarle:feat/t3-traces-go

Conversation

@westarle

Copy link
Copy Markdown
Contributor

This PR implements T3 spans (Client Request) in gax.Invoke when the TRACING feature flag is enabled.

Key changes:

  • Added StartClientRequestSpan and EndClientRequestSpan in telemetry.go to handle the lifecycle of T3 spans.
  • Hooked these into Invoke using a closure pattern to avoid leaking OpenTelemetry types into invoke.go.
  • The T3 span name is read from the context (key: client_span_name) injected by the generator, falling back to rpc_method if missing.
  • Populates error attributes on the span using the existing ExtractTelemetryErrorInfo helper.

Testing:

  • Added a new test suite invoke_tracing_test.go that uses OTel's tracetest to verify that spans are correctly created and populated with attributes. All tests in v2 passed.

@westarle westarle changed the title impl: add T3 spans to gax.Invoke impl(v2): add client request spans to gax.Invoke Apr 20, 2026
@westarle
westarle force-pushed the feat/t3-traces-go branch from b1ae979 to b282732 Compare April 20, 2026 21:48
@westarle
westarle force-pushed the feat/t3-traces-go branch from b282732 to 8c4149c Compare April 20, 2026 21:53
@bhshkh
bhshkh force-pushed the feat/t3-traces-go branch from 559ef22 to 04ddc3d Compare June 23, 2026 06:54
…path

Eliminates an unnecessary heap allocation on the critical hot path of every API call. Synchronous, in-memory metric recording (`histogram.Record()`) does not perform I/O and is completely unaffected by context cancellation.

Furthermore, trace context values (active spans) remain fully extractable via `trace.SpanContextFromContext(ctx)` even if the context's `Done()` channel has been closed. Thus, wrapping the context with `WithoutCancel` is redundant.
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