Skip to content

Commit

Permalink
Add one more specs for more advanced query building in Excon
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikspang committed Nov 5, 2024
1 parent e226e19 commit bf3be51
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions sentry-ruby/spec/sentry/excon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,34 @@
})
end

it "records the request's span with advanced query string in data" do
Excon.stub({}, { body: '', status: 200 })

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

connection = Excon.new('http://example.com/path')
response = connection.get(mock: true, query: { foo: 'bar', baz: [1, 2], qux: { a: 1, b: 2 } })

expect(response.status).to eq(200)
expect(transaction.span_recorder.spans.count).to eq(2)

request_span = transaction.span_recorder.spans.last
expect(request_span.op).to eq("http.client")
expect(request_span.origin).to eq("auto.http.excon")
expect(request_span.start_timestamp).not_to be_nil
expect(request_span.timestamp).not_to be_nil
expect(request_span.start_timestamp).not_to eq(request_span.timestamp)
expect(request_span.description).to eq("GET http://example.com/path")
expect(request_span.data).to eq({
"http.response.status_code" => 200,
"url" => "http://example.com/path",
"http.request.method" => "GET",
# This equals: "foo=bar&baz[]=1&baz[]=2&qux[a]=1&qux[b]=2"
"http.query" => "foo=bar&baz%5B%5D=1&baz%5B%5D=2&qux%5Ba%5D=1&qux%5Bb%5D=2"
})
end

it "records breadcrumbs" do
Excon.stub({}, { body: '', status: 200 })

Expand Down

0 comments on commit bf3be51

Please sign in to comment.