feat(gax): accept clientOptions in createApiCall for telemetry tracing - #9068
feat(gax): accept clientOptions in createApiCall for telemetry tracing#9068shivanee-p wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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.
| // 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; |
There was a problem hiding this comment.
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.
| 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'; |
e373eaf to
e8c906c
Compare
No description provided.