Skip to content

feat(bigquery): add opentelemetry W3C Trace Context to headers#12203

Open
ldetmer wants to merge 2 commits intomainfrom
add-trace-headers
Open

feat(bigquery): add opentelemetry W3C Trace Context to headers#12203
ldetmer wants to merge 2 commits intomainfrom
add-trace-headers

Conversation

@ldetmer
Copy link
Copy Markdown
Contributor

@ldetmer ldetmer commented Mar 25, 2026

This adds header value using OpenTelemetry's W3C Trace Context Propagation.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 observability of BigQuery operations by integrating OpenTelemetry's W3C Trace Context propagation. By injecting trace and span IDs into HTTP request headers, it enables seamless end-to-end distributed tracing, which is crucial for monitoring and debugging complex service interactions involving BigQuery.

Highlights

  • OpenTelemetry W3C Trace Context Propagation: Implemented the propagation of OpenTelemetry W3C Trace Context into HTTP request headers for BigQuery telemetry, ensuring distributed traces are correctly linked across services.
  • New Test Case for Trace Context: Added a dedicated test case to validate that the W3C traceparent header is correctly set with the active span's trace and span IDs during HTTP requests.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 W3C Trace Context propagation for HTTP requests within the HttpTracingRequestInitializer in the BigQuery telemetry module. This involves adding OpenTelemetry imports, injecting the trace context into outgoing HttpRequest headers, and a new unit test to verify this functionality. A review comment suggests an improvement to use a method reference (HttpHeaders::set) instead of a lambda for injecting the trace context, citing improved readability and adherence to the Google Java Style Guide.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ldetmer ldetmer marked this pull request as ready for review March 26, 2026 14:29
@ldetmer ldetmer requested review from a team as code owners March 26, 2026 14:29
@ldetmer ldetmer requested review from jinseopkim0 and lqiu96 March 26, 2026 14:30
return;
}
// propagate the W3C Trace Context (traceID and spanID) from the active span in headers
W3CTraceContextPropagator.getInstance()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, this is to ensure that the parent span's traceID and SpanID values are injected into the current span?

Or is this doing something different?

Copy link
Copy Markdown
Contributor Author

@ldetmer ldetmer Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is just adding the traceID/spanID into a standard opentelemetry header for tracking purposes. See requirement here. Using the library ensures it pulls the current span from context and creates it following the W3C standard for header label/format.

@ldetmer ldetmer requested review from a team and blakeli0 March 27, 2026 18:59
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