Skip to content

Add more RequestMetadata attributes to trace spans#12038

Open
bduffany wants to merge 1 commit intomasterfrom
bazel-request-md-trace
Open

Add more RequestMetadata attributes to trace spans#12038
bduffany wants to merge 1 commit intomasterfrom
bazel-request-md-trace

Conversation

@bduffany
Copy link
Copy Markdown
Member

@bduffany bduffany commented Apr 29, 2026

Also, don't unnecessarily set attributes if we're not recording.

@bduffany bduffany requested review from Copilot and vanja-p April 29, 2026 19:50
@bduffany bduffany marked this pull request as draft April 29, 2026 19:51
@bduffany bduffany force-pushed the bazel-request-md-trace branch 3 times, most recently from ac6946a to 29feac8 Compare April 29, 2026 19:54
@bduffany bduffany marked this pull request as ready for review April 29, 2026 19:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands OpenTelemetry root span enrichment using Bazel RequestMetadata, adding more queryable attributes to traces while avoiding attaching the full serialized metadata blob.

Changes:

  • Extend request metadata extraction to also read RequestMetadata bytes from context.Context values (in addition to incoming gRPC metadata).
  • Add TraceAttributes() and SetTraceAttributes() helpers to convert RequestMetadata into span attributes and apply them only when the span is recording.
  • Refactor gRPC interceptors to use the new helper for propagating request metadata onto spans, and update Bazel deps accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
server/util/bazel_request/bazel_request.go Adds trace attribute helpers and broadens where request metadata bytes can be sourced from (incoming metadata or context value).
server/util/bazel_request/BUILD Adds OpenTelemetry attribute/trace deps required by the new helpers.
server/rpc/interceptors/interceptors.go Switches span enrichment to call the new centralized request-metadata-to-span helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/util/bazel_request/bazel_request.go Outdated
Comment thread server/rpc/interceptors/interceptors.go Outdated
@bduffany bduffany force-pushed the bazel-request-md-trace branch from 29feac8 to 3cdbdd7 Compare April 29, 2026 20:01
@bduffany bduffany force-pushed the bazel-request-md-trace branch from 3cdbdd7 to af95995 Compare April 29, 2026 20:02
@bduffany bduffany changed the title Add more RequestMetadata attributes to root trace spans Add more RequestMetadata attributes to trace spans Apr 29, 2026
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.

3 participants