Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the BigQuery client's OpenTelemetry tracing capabilities by incorporating retry attempt information directly into the generated spans. This provides valuable context for debugging and analyzing the behavior of requests that undergo retries, allowing developers to quickly identify and understand the impact of transient errors and retry logic on overall request latency and success rates. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces OpenTelemetry tracing for BigQuery retry attempts. It adds a ThreadLocal variable to BigQueryRetryAlgorithm to store the current retry count, which is then used by HttpTracingRequestInitializer to add an HTTP_REQUEST_RESEND_COUNT attribute to the HTTP request span. New tests have been added to validate this functionality. Feedback includes a high-severity concern regarding potential ThreadLocal leakage that could lead to incorrect telemetry data, with a suggestion to reset the ThreadLocal after use. Additionally, a medium-severity design concern was raised about exposing ThreadLocal as a public static final field, which is considered an anti-pattern and creates tight coupling, though it's accepted for now due to current framework constraints.
...igquery/src/main/java/com/google/cloud/bigquery/telemetry/HttpTracingRequestInitializer.java
Outdated
Show resolved
Hide resolved
|
|
||
| private static final Logger LOG = Logger.getLogger(BigQueryRetryAlgorithm.class.getName()); | ||
| private static final UUID RETRY_UUID = UUID.randomUUID(); | ||
| public static final ThreadLocal<Integer> CURRENT_ATTEMPT = ThreadLocal.withInitial(() -> 0); |
There was a problem hiding this comment.
Exposing a ThreadLocal as a public static final field is generally considered an anti-pattern as it creates a hidden, global-like dependency between components and can be prone to misuse. While it seems necessary here to communicate the retry state to HttpTracingRequestInitializer due to framework constraints, it would be ideal to find a way to pass this context explicitly if possible in the future. For now, this is acceptable, but please be mindful of the tight coupling it introduces.
There was a problem hiding this comment.
added helper methods, but note this isn't something we have easy access too, as retry logic is handled inside of apiary client, so we do have to expose it somehow to the interceptor.
This adds attribute for HTTP_REQUEST_RESEND_COUNT to span tracing. This only gets populated in case of a retry on the client side.
no resend attribute on first attempt
example retry 1
example retry 4