Skip to content

Commit

Permalink
Describe Rails subscriber implementation
Browse files Browse the repository at this point in the history
The agent uses a non-traditional way to subscribe to Rails events.
Instead of passing a block to ActiveSupport::Notifications.subscribe, the
agent defines a #start and #finish method, which Rails responds to.
This is due to a threading issue discovered on initial instrumentation.
Issue: rails/rails#12069
Rails code: https://github.com/rails/rails/blob/ed5af004598fa7645fec2210453cca00f4b59168/activesupport/lib/active_support/notifications/fanout.rb#L320
  • Loading branch information
hannahramadan committed Aug 29, 2023
1 parent 86cdeee commit 1df9227
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def self.subscribe(pattern)
end
end

# The agent doesn't use the traditional ActiveSupport::Notifications.subscribe
# pattern due to threading issues discovered on initial instrumentation.
# Instead we define a #start and #finish method, which Rails responds to.
def start(name, id, payload)
return unless state.is_execution_traced?

Expand Down

0 comments on commit 1df9227

Please sign in to comment.