Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug Rack event finish issue #1394

Merged
merged 1 commit into from
Mar 20, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: change
---

Differentiate between `process_request.rack` events. Add the callback that triggered the event in the event title for debugging purposes.
4 changes: 2 additions & 2 deletions lib/appsignal/rack/event_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def on_start(request, _response)

Appsignal::Rack::EventHandler
.safe_execution("Appsignal::Rack::EventHandler's after_reply") do
transaction.finish_event("process_request.rack", "", "")
transaction.finish_event("process_request.rack", "callback: after_reply", "")
queue_start = Appsignal::Rack::Utils.queue_start_from(request.env)
transaction.set_queue_start(queue_start) if queue_start
end
Expand Down Expand Up @@ -111,7 +111,7 @@ def on_finish(request, response)
return unless transaction

self.class.safe_execution("Appsignal::Rack::EventHandler#on_finish") do
transaction.finish_event("process_request.rack", "", "")
transaction.finish_event("process_request.rack", "callback: on_finish", "")
transaction.add_params_if_nil { request.params }
transaction.add_headers_if_nil { request.env }
transaction.add_session_data_if_nil do
Expand Down
9 changes: 8 additions & 1 deletion spec/lib/appsignal/rack/event_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def on_error(error)
expect(Appsignal::Transaction.current).to be_kind_of(Appsignal::Transaction::NilTransaction)

expect(last_transaction.ext.queue_start).to eq(queue_start_time)
expect(last_transaction).to include_event(
"name" => "process_request.rack",
"title" => "callback: after_reply"
)
end

context "with error inside rack.after_reply handler" do
Expand Down Expand Up @@ -386,7 +390,10 @@ def on_finish(given_request = request, given_response = response)
on_start
on_finish

expect(last_transaction).to include_event("name" => "process_request.rack")
expect(last_transaction).to include_event(
"name" => "process_request.rack",
"title" => "callback: on_finish"
)
end

context "with response" do
Expand Down
Loading