Issue Description
Sentry::Utils::HttpTracing#set_propagation_headers unconditionally overwrites all propagation headers on outgoing HTTP requests using req[k] = v. While this is fine for the Sentry-specific sentry-trace header, the baggage header is a W3C standard shared across multiple systems. Any pre-existing baggage entries (e.g. set by OpenTelemetry, application code, or other instrumentation) are silently discarded.
The affected code is in sentry-ruby/lib/sentry/utils/http_tracing.rb#L14-L16:
defset_propagation_headers(req)Sentry.get_trace_propagation_headers&.each{ |k,v| req[k]=v}endReproduction Steps
- Set a custom
baggage header on an outgoing HTTP request (e.g. routingKey=myvalue) - Ensure
propagate_traces is enabled in Sentry config and the target URL matches trace_propagation_targets - Make the HTTP request using
Net::HTTP, Faraday, or Excon - Inspect the outgoing request headers
require"net/http"Sentry.initdo |config|
config.dsn="https://key@sentry.io/1"config.traces_sample_rate=1.0config.propagate_traces=trueenduri=URI("https://example.com/api")req=Net::HTTP::Get.new(uri)req["baggage"]="routingKey=myvalue,tenantId=123"# After Sentry instruments this request, the baggage header# will only contain sentry-* entries -- the original values are lostNet::HTTP.start(uri.hostname,uri.port,use_ssl: true){ |http| http.request(req)}Expected Behavior
When a baggage header already exists on the outgoing request, Sentry should merge its entries with the existing value by joining them with a comma (,), as per the W3C Bagga
ge specification. The resulting header should look like:
sentry-trace_id=abc123,sentry-environment=production,routingKey=myvalue,tenantId=123
Actual Behavior
Sentry replaces the entire baggage header with only Sentry's entries. The resulting header contains:
sentry-trace_id=abc123,sentry-environment=production,sentry-release=xyz,sentry-public_key=key123
The original routingKey=myvalue,tenantId=123 entries are lost.
Ruby Version
All (not version-specific)
SDK Version
All current versions (verified on 6.5.0)
Integration and Its Version
No response
Sentry Config
No response
Issue Description
Sentry::Utils::HttpTracing#set_propagation_headersunconditionally overwrites all propagation headers on outgoing HTTP requests usingreq[k] = v. While this is fine for the Sentry-specificsentry-traceheader, thebaggageheader is a W3C standard shared across multiple systems. Any pre-existing baggage entries (e.g. set by OpenTelemetry, application code, or other instrumentation) are silently discarded.The affected code is in
sentry-ruby/lib/sentry/utils/http_tracing.rb#L14-L16:Reproduction Steps
baggageheader on an outgoing HTTP request (e.g.routingKey=myvalue)propagate_tracesis enabled in Sentry config and the target URL matchestrace_propagation_targetsNet::HTTP,Faraday, orExconExpected Behavior
When a
baggageheader already exists on the outgoing request, Sentry should merge its entries with the existing value by joining them with a comma (,), as per the W3C Baggage specification. The resulting header should look like:
Actual Behavior
Sentry replaces the entire
baggageheader with only Sentry's entries. The resulting header contains:The original
routingKey=myvalue,tenantId=123entries are lost.Ruby Version
All (not version-specific)
SDK Version
All current versions (verified on 6.5.0)
Integration and Its Version
No response
Sentry Config
No response