Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Bug Fixes 🐛

- Do not overwrite baggage header contents if it already exists by @jakubsomonday in [#2894](https://github.com/getsentry/sentry-ruby/pull/2894)
- (rails) Set mechanism.handled based on error handling status by @solnic in [#2892](https://github.com/getsentry/sentry-ruby/pull/2892)
- Copy event processors on Scope#dup by @sl0thentr0py in [#2893](https://github.com/getsentry/sentry-ruby/pull/2893)
- Map `trilogy` database adapter to `mysql` for Query Insights compatibility by @krismichalski in [#2656](https://github.com/getsentry/sentry-ruby/pull/2656)
Expand Down
8 changes: 7 additions & 1 deletion sentry-ruby/lib/sentry/utils/http_tracing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ def set_span_info(sentry_span, request_info, response_status)
end

def set_propagation_headers(req)
Sentry.get_trace_propagation_headers&.each { |k, v| req[k] = v }
Sentry.get_trace_propagation_headers&.each do |k, v|
if k == BAGGAGE_HEADER_NAME && req[k]
req[k] = "#{v},#{req[k]}"
else
req[k] = v
end
end
end

def record_sentry_breadcrumb(request_info, response_status)
Expand Down
39 changes: 39 additions & 0 deletions sentry-ruby/spec/sentry/net/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,45 @@
)
end

it "merges baggage header with pre-existing baggage on the request" do
stub_normal_response

uri = URI("http://example.com/path")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
request["baggage"] = "routingKey=myvalue,tenantId=123"

transaction = Sentry.start_transaction
Sentry.get_current_scope.set_span(transaction)

response = http.request(request)

expect(response.code).to eq("200")
request_span = transaction.span_recorder.spans.last
sentry_baggage = request_span.to_baggage

expect(request["baggage"]).to include(sentry_baggage)
expect(request["baggage"]).to include("routingKey=myvalue,tenantId=123")
expect(request["baggage"]).to eq("#{sentry_baggage},routingKey=myvalue,tenantId=123")
end

it "sets baggage header normally when no pre-existing baggage on the request" do
stub_normal_response

uri = URI("http://example.com/path")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)

transaction = Sentry.start_transaction
Sentry.get_current_scope.set_span(transaction)

response = http.request(request)

expect(response.code).to eq("200")
request_span = transaction.span_recorder.spans.last
expect(request["baggage"]).to eq(request_span.to_baggage)
end

context "with config.propagate_traces = false" do
before do
Sentry.configuration.propagate_traces = false
Expand Down
Loading