Skip to content

feat(gax): accept clientOptions in createApiCall for telemetry tracing - #9068

Draft
shivanee-p wants to merge 2 commits into
shivaneep-o11y-tracer-helperfrom
shivaneep-o11y-gax-tracing
Draft

feat(gax): accept clientOptions in createApiCall for telemetry tracing#9068
shivanee-p wants to merge 2 commits into
shivaneep-o11y-tracer-helperfrom
shivaneep-o11y-gax-tracing

Conversation

@shivanee-p

Copy link
Copy Markdown
Contributor

No description provided.

@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 the createApiCall function to accept clientOptions and introduces a tracingEnabled flag based on clientOptions.enableTelemetryTracing and the GOOGLE_SDK_NODE_EXPERIMENTAL_O11Y_ENABLED environment variable. Feedback suggests explicitly comparing the environment variable to the string 'true' and casting the telemetry option to a boolean to prevent truthy evaluation of a 'false' string in Node.js.

Comment thread core/packages/gax/src/createApiCall.ts Outdated
// the following apiCaller will be used for all calls of this function...
const apiCaller = createAPICaller(settings, descriptor);

const tracingEnabled = clientOptions?.enableTelemetryTracing && process.env.GOOGLE_SDK_NODE_EXPERIMENTAL_O11Y_ENABLED;

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.

medium

In Node.js, environment variables retrieved from process.env are always strings (or undefined). If process.env.GOOGLE_SDK_NODE_EXPERIMENTAL_O11Y_ENABLED is set to "false", it will still evaluate to a truthy value in a boolean context. To prevent unexpected behavior, explicitly check if the environment variable is equal to "true" and ensure tracingEnabled is a strict boolean.

Suggested change
const tracingEnabled = clientOptions?.enableTelemetryTracing && process.env.GOOGLE_SDK_NODE_EXPERIMENTAL_O11Y_ENABLED;
const tracingEnabled = !!clientOptions?.enableTelemetryTracing && process.env.GOOGLE_SDK_NODE_EXPERIMENTAL_O11Y_ENABLED === 'true';

@shivanee-p
shivanee-p changed the base branch from shivaneep-o11y-flag to shivaneep-o11y-tracer-helper August 4, 2026 01:53
@shivanee-p
shivanee-p force-pushed the shivaneep-o11y-gax-tracing branch from e373eaf to e8c906c Compare August 4, 2026 01:55
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