feat(spanner): optimize RequestId propagation and minimize OpenTelemetry active tracing overhead#8329
feat(spanner): optimize RequestId propagation and minimize OpenTelemetry active tracing overhead#8329surbhigarg92 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to check if tracing is enabled before performing instrumentation, improving performance by avoiding unnecessary work when tracing is inactive. It also optimizes project ID retrieval in prepareGapicRequest_ by caching the result and refactors request ID header injection. Feedback identifies a logic bug in the isTracingEnabled caching mechanism regarding the precedence of custom providers and global state pollution. Additionally, suggestions were made to correct a copy-pasted docstring and to utilize the existing craftRequestId utility to maintain consistency.
…try active tracing overhead
5ea84d5 to
652517b
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces conditional tracing logic to the Spanner client, ensuring that observability features like context propagation and request ID attribution are only active when tracing is enabled. It also refactors project ID replacement and request ID header generation for improved efficiency. Feedback from the review highlights critical issues where project ID and resource header replacements are incorrectly skipped after the first request, which could lead to incorrect headers in subsequent calls. Additionally, the reviewer suggested refining the tracing enablement cache to avoid permanently disabling tracing if the client is initialized before the OpenTelemetry SDK is fully configured.
a983da5 to
571de00
Compare
571de00 to
85e4b52
Compare
ed42be6 to
52ee386
Compare
52ee386 to
728a980
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces optimizations to conditionally enable tracing and context propagation in the Spanner client based on whether global tracing is active, including a 10-second TTL cache for global tracing checks. It also refactors request ID header generation and adds corresponding unit tests. The review feedback correctly points out that relying on delegate.constructor.name for tracer provider detection is fragile due to code minification in production. It suggests a robust, minification-safe alternative by checking for a valid, non-zero traceId from a generated span, and provides the necessary updates for both the implementation and the test stubs.
Optimize RequestId propagation and minimize OpenTelemetry active tracing overhead.