Skip to content

Commit

Permalink
Report request headers for webmachine apps (#1177)
Browse files Browse the repository at this point in the history
I noticed we don't store the request headers for webmachine apps.
Track these on the transaction with our new `set_headers_if_nil` helper.
  • Loading branch information
tombruijn authored Jul 10, 2024
1 parent 2d2e0e4 commit fcfb7a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changesets/report-request-headers-for-webmachine-apps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: add
---

Report request headers for webmachine apps.
1 change: 1 addition & 0 deletions lib/appsignal/integrations/webmachine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def run
ensure
transaction.set_action_if_nil("#{resource.class.name}##{request.method}")
transaction.set_params_if_nil(request.query)
transaction.set_headers_if_nil { request.headers if request.respond_to?(:headers) }

Appsignal::Transaction.complete_current! unless has_parent_transaction
end
Expand Down
14 changes: 13 additions & 1 deletion spec/lib/appsignal/integrations/webmachine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ def headers
Webmachine::Request.new(
"GET",
"http://google.com:80/foo?param1=value1&param2=value2",
{},
{
"REQUEST_METHOD" => "GET",
"PATH_INFO" => "/some/path",
"ignored_header" => "something"
},
nil
)
end
Expand Down Expand Up @@ -81,6 +85,14 @@ def to_html
expect(last_transaction).to include_params("param1" => "value1", "param2" => "value2")
end

it "sets the headers" do
fsm.run
expect(last_transaction).to include_environment(
"REQUEST_METHOD" => "GET",
"PATH_INFO" => "/some/path"
)
end

it "closes the transaction" do
fsm.run
expect(last_transaction).to be_completed
Expand Down

0 comments on commit fcfb7a0

Please sign in to comment.