refactor(api,dashboard-api): Allow traceparent propagation into API#2337
refactor(api,dashboard-api): Allow traceparent propagation into API#2337ben-fornefeld wants to merge 4 commits intomainfrom
Conversation
PR SummaryMedium Risk Overview Reviewed by Cursor Bugbot for commit 044e2f1. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
LGTM — clean, well-tested observability change.
Extended reasoning...
Overview
This PR modifies the Gin OTel tracing middleware to extract W3C trace context from incoming requests (instead of stripping it), starts server spans as children of the remote parent, and allows traceparent/tracestate/baggage through CORS in both the API and dashboard-API. A new regression test covers the propagation path.
Security risks
Accepting caller-provided trace context means external clients can influence which trace ID their requests appear under. This is standard, expected behavior for W3C traceparent — the server still creates its own span; it simply links it to the caller's trace. There is no auth bypass, data exposure, or business logic impact. The baggage header is also accepted via CORS; if downstream code ever reads baggage values for business decisions this would warrant scrutiny, but that is not the case here.
Level of scrutiny
Low. The change touches only telemetry/observability code and CORS header allow-lists. It follows established OpenTelemetry conventions, has no effect on request authorization or data handling, and includes a targeted test.
Other factors
The test in middleware_test.go covers the core invariant (span is a child of the remote parent and carries the correct trace ID). No prior review comments exist. Bug hunting found no issues.
| "google.golang.org/grpc/encoding/gzip" | ||
| ) | ||
|
|
||
| var contextPropagationHeaders = NewTextPropagator().Fields() |
There was a problem hiding this comment.
We won't necessarily be using this one:
| var contextPropagationHeaders = NewTextPropagator().Fields() | |
| var contextPropagationHeaders []string | |
| func init() { | |
| contextPropagationHeaders = otel.GetTextMapPropagator().Fields() | |
| } |
Summary