Skip to content

feat(gax): emit T4 attempt spans - #9496

Merged
shivanee-p merged 23 commits into
mainfrom
shivaneep-o11y-t4-headers
Oct 3, 2026
Merged

shivanee-p merged 23 commits into
mainfrom
shivaneep-o11y-t4-headers

Conversation

@shivanee-p

@shivanee-p shivanee-p commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Emits OpenTelemetry tracing spans per-attempt transport spans (SpanKind.CLIENT) directly from google-gax for both gRPC and HTTP/REST fallback calls

Key Changes:

  • Added traceAttempt() and AttemptTraceContext to wrap each individual transport attempt (<apiName>/<methodName>, SpanKind.CLIENT), parented to the enclosing T3 client call span (<ClientName>.<MethodName>, SpanKind.INTERNAL)
  • Populated T4 span attributes: gcp.client.service/rpc.system, rpc.method/http.request.method, url.domain, server.address, server.port, gcp.grpc.resend_count/http.request.resend_count, error.type, span error status, and exception events on attempt failures
  • Propagated servicePath / apiEndpoint and port from GrpcClient options into constructSettings otherArgs so static trace context resolves custom endpoints and ports
  • Added unit tests covering traceAttempt, T3/T4 parent-child hierarchies across unary, retries, and streaming calls, HTTP verb resolution, and transport-specific status code attributes

@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 implements OpenTelemetry trace context propagation into gRPC and HTTP/REST metadata within the gax package, introducing an isMetadata utility and a comprehensive test suite. The review feedback points out that plain object metadata should be cloned before injecting the active span context to prevent unintended mutations and trace context leakage.

Comment thread core/packages/gax/src/normalCalls/timeout.ts Outdated
@shivanee-p
shivanee-p force-pushed the shivaneep-o11y-t4-headers branch from c711b36 to 4bdc143 Compare October 1, 2026 20:36
@shivanee-p
shivanee-p marked this pull request as ready for review October 1, 2026 20:36
@shivanee-p
shivanee-p requested a review from a team as a code owner October 1, 2026 20:36
@github-actions
github-actions Bot requested a review from danieljbruce October 1, 2026 20:36
@quirogas
quirogas requested review from quirogas and removed request for danieljbruce October 1, 2026 20:44
@quirogas
quirogas marked this pull request as draft October 1, 2026 20:51
@shivanee-p
shivanee-p force-pushed the shivaneep-o11y-t4-headers branch from 7e54208 to 396dcd0 Compare October 2, 2026 00:56
@shivanee-p shivanee-p changed the title feat(gax): inject active OpenTelemetry span context into header metadata feat(gax): emit T4 attempt spans Oct 2, 2026
@shivanee-p

Copy link
Copy Markdown
Contributor Author

/gemini review

@shivanee-p
shivanee-p marked this pull request as ready for review October 2, 2026 01:59
@github-actions
github-actions Bot requested a review from bshaffer October 2, 2026 02:00
@shivanee-p
shivanee-p removed request for a team and bshaffer October 2, 2026 02:00

@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 Tier 4 (T4) per-attempt tracing spans (OpenTelemetry CLIENT spans) parented under the T3 client request spans in google-gax. It adds traceAttempt in TracerHelper.ts to manage individual RPC transport attempts, captures service path and port configurations in both gRPC and fallback clients, and updates unit tests to verify the new span relationships and attributes. Feedback on the changes highlights a critical issue in createApiCall.ts where mutating the outer func parameter inside invokeCall causes a memory leak and call stack growth across multiple API calls; a fix is suggested to wrap currentApiCaller instead.

Comment thread core/packages/gax/src/createApiCall.ts
@github-actions
github-actions Bot requested a review from danieljbruce October 2, 2026 05:13
@shivanee-p
shivanee-p removed the request for review from danieljbruce October 2, 2026 15:13
@github-actions
github-actions Bot requested a review from feywind October 2, 2026 15:28
Comment thread core/packages/gax/src/createApiCall.ts Outdated
@shivanee-p
shivanee-p merged commit 51aedce into main Oct 3, 2026
46 checks passed
@shivanee-p
shivanee-p deleted the shivaneep-o11y-t4-headers branch October 3, 2026 05:37
@release-please release-please Bot mentioned this pull request Oct 2, 2026
shivanee-p pushed a commit that referenced this pull request Oct 5, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>google-gax: 6.11.0</summary>

##
[6.11.0](google-gax-v6.10.0...google-gax-v6.11.0)
(2026-10-03)


### Features

* **gax:** Emit T4 attempt spans
([#9496](#9496))
([51aedce](51aedce))


### Bug Fixes

* **gax:** Propagate chunk granularity on resume and preserve retry
error details
([#9480](#9480))
([02b9478](02b9478))
</details>

<details><summary>retry-request: 9.0.2</summary>

##
[9.0.2](retry-request-v9.0.1...retry-request-v9.0.2)
(2026-10-03)


### Bug Fixes

* **retry-request:** Move teeny-request to devDependencies
([#9500](#9500))
([068fe52](068fe52))
</details>

<details><summary>test-utils: 0.2.0</summary>

##
[0.2.0](test-utils-v0.1.0...test-utils-v0.2.0)
(2026-10-03)


### Features

* **test-utils:** Add runtime detection predicates and cross-engine
assertion helpers
([#9492](#9492))
([f971bb5](f971bb5))
</details>

<details><summary>chat: 0.34.0</summary>

##
[0.34.0](chat-v0.33.1...chat-v0.34.0)
(2026-10-03)


### Features

* Update API sources and regenerate
([#9481](#9481))
([35a2b9a](35a2b9a))
</details>

<details><summary>aiplatform: 7.5.0</summary>

##
[7.5.0](aiplatform-v7.4.1...aiplatform-v7.5.0)
(2026-10-03)


### Features

* Update API sources and regenerate
([#9481](#9481))
([35a2b9a](35a2b9a))
</details>

<details><summary>bigtable-api: 0.10.0</summary>

##
[0.10.0](bigtable-api-v0.9.0...bigtable-api-v0.10.0)
(2026-10-03)


### Features

* Update API sources and regenerate
([#9427](#9427))
([5cd945d](5cd945d))
* Update API sources and regenerate
([#9472](#9472))
([514e2f6](514e2f6))
</details>

<details><summary>procurement: 0.10.0</summary>

##
[0.10.0](procurement-v0.9.1...procurement-v0.10.0)
(2026-10-03)


### Features

* Update API sources and regenerate
([#9481](#9481))
([35a2b9a](35a2b9a))
</details>

<details><summary>commerceproducer: 0.6.0</summary>

##
[0.6.0](commerceproducer-v0.5.0...commerceproducer-v0.6.0)
(2026-10-03)


### Features

* Update API sources and regenerate
([#9481](#9481))
([35a2b9a](35a2b9a))
</details>

<details><summary>compute: 7.7.0</summary>

##
[7.7.0](compute-v7.6.0...compute-v7.7.0)
(2026-10-03)


### Features

* Update API sources and regenerate
([#9481](#9481))
([35a2b9a](35a2b9a))
* Update Compute v1 API to version 2026-09-01
([#9503](#9503))
([02e3361](02e3361))


### Bug Fixes

* All AggregatedList RPCs behavior is now return_partial_success=true
([02e3361](02e3361))
* All AggregatedList RPCs return_partial_success fields removed
([02e3361](02e3361))
</details>

<details><summary>products: 0.12.0</summary>

##
[0.12.0](products-v0.11.1...products-v0.12.0)
(2026-10-03)


### Features

* Update API sources and regenerate
([#9481](#9481))
([35a2b9a](35a2b9a))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
danieljbruce added a commit that referenced this pull request Oct 6, 2026
…9539)

### Summary

Fixes the `@google-cloud/pubsub` pack-and-install system test failure
(`should be able to use the d.ts`):

```
node_modules/@google-cloud/pubsub/build/src/pubsub.d.ts:29:18 - error TS2430: Interface 'ClientConfig' incorrectly extends interface 'GrpcClientOptions'.
  Types of property 'port' are incompatible.
    Type 'string | number | undefined' is not assignable to type 'number | undefined'.
      Type 'string' is not assignable to type 'number'.
```

### Root Cause

In #9496 (released in `[email protected]`), `GrpcClientOptions` added
`port?: number;`. In `@google-cloud/pubsub`, `ClientConfig` extends
`gax.GrpcClientOptions` but declared `port?: string | number;`, causing
TypeScript compilation with `skipLibCheck: false` to fail when resolving
`[email protected]+`.

Internally, `PubSub#determineBaseUrl_` already parses `port` as a
`number` (or `undefined`), matching `gax.GrpcClientOptions` and
`gax.ClientOptions`.

### Changes

- Updated `ClientConfig.port` in `handwritten/pubsub/src/pubsub.ts` from
`string | number` to `number`.
shivanee-p added a commit that referenced this pull request Oct 6, 2026
Widens `port` from `number` to `number | string` on `GrpcClientOptions`
and `ClientStubOptions` in `google-gax` to restore type compatibility
with downstream client libraries (such as `@google-cloud/pubsub`, whose
`ClientConfig` extends `gax.GrpcClientOptions` with `port?: string |
number`)

#9496 added `port?: number` to `GrpcClientOptions` (released in
`[email protected]`). Because `@google-cloud/pubsub`'s `ClientConfig`
interface extends `gax.GrpcClientOptions` and declares `port?: string |
number`, TypeScript compilation with `skipLibCheck: false` (such as in
`@google-cloud/pubsub`'s `system-test/install.ts`) fails
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