-
-
Notifications
You must be signed in to change notification settings - Fork 532
Description
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:
def set_propagation_headers(req)
Sentry.get_trace_propagation_headers&.each { |k, v| req[k] = v }
endReproduction Steps
- Set a custom
baggageheader on an outgoing HTTP request (e.g.routingKey=myvalue) - Ensure
propagate_tracesis enabled in Sentry config and the target URL matchestrace_propagation_targets - Make the HTTP request using
Net::HTTP,Faraday, orExcon - Inspect the outgoing request headers
require "net/http"
Sentry.init do |config|
config.dsn = "https://key@sentry.io/1"
config.traces_sample_rate = 1.0
config.propagate_traces = true
end
uri = 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 lost
Net::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
Metadata
Metadata
Assignees
Fields
Give feedbackProjects
Status