Skip to content

Commit

Permalink
readme: Clarify AS::Notification.subscribe arguments (#654)
Browse files Browse the repository at this point in the history
* fix AS::Notification.subscribe arguments in README.md

* event_id -> instrumenter_id
  • Loading branch information
tisba authored Mar 10, 2024
1 parent 429fb7f commit d7a7a8b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Rack::Attack.track("special_agent", limit: 6, period: 60) do |req|
end

# Track it using ActiveSupport::Notification
ActiveSupport::Notifications.subscribe("track.rack_attack") do |name, start, finish, request_id, payload|
ActiveSupport::Notifications.subscribe("track.rack_attack") do |name, start, finish, instrumenter_id, payload|
req = payload[:request]
if req.env['rack.attack.matched'] == "special_agent"
Rails.logger.info "special_agent: #{req.path}"
Expand Down Expand Up @@ -383,7 +383,7 @@ To get notified about specific type of events, subscribe to the event name follo
E.g. for throttles use:

```ruby
ActiveSupport::Notifications.subscribe("throttle.rack_attack") do |name, start, finish, request_id, payload|
ActiveSupport::Notifications.subscribe("throttle.rack_attack") do |name, start, finish, instrumenter_id, payload|
# request object available in payload[:request]

# Your code here
Expand All @@ -393,7 +393,7 @@ end
If you want to subscribe to every `rack_attack` event, use:

```ruby
ActiveSupport::Notifications.subscribe(/rack_attack/) do |name, start, finish, request_id, payload|
ActiveSupport::Notifications.subscribe(/rack_attack/) do |name, start, finish, instrumenter_id, payload|
# request object available in payload[:request]

# Your code here
Expand Down

0 comments on commit d7a7a8b

Please sign in to comment.