Skip to content

Commit

Permalink
Move up creation of Rack instrumentation event (#1339)
Browse files Browse the repository at this point in the history
We see a small difference between the transaction duration and the total
duration of child span groups.

Move up the transaction's Rack event creation so it happens directly
after the transaction is created to minimize this difference.

Context:
https://appsignal.slack.com/archives/C7XHXQ7N0/p1733142713081549?thread_ts=1733126790.603229&cid=C7XHXQ7N0
  • Loading branch information
tombruijn authored Dec 4, 2024
1 parent 37a0da4 commit 95c3780
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changesets/reduce-rack-transaction-event-creation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: change
---

Minimize difference between Rack transaction duration and total child event durations.
2 changes: 1 addition & 1 deletion lib/appsignal/rack/event_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def on_start(request, _response)
return unless request_handler?(request.env[APPSIGNAL_EVENT_HANDLER_ID])

transaction = Appsignal::Transaction.create(Appsignal::Transaction::HTTP_REQUEST)
transaction.start_event
request.env[APPSIGNAL_TRANSACTION] = transaction

request.env[RACK_AFTER_REPLY] ||= []
Expand All @@ -83,7 +84,6 @@ def on_start(request, _response)
# One such scenario is when a Puma "lowlevel_error" occurs.
Appsignal::Transaction.complete_current!
end
transaction.start_event
end
end

Expand Down

0 comments on commit 95c3780

Please sign in to comment.