mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update instrumentation guides w/optional block
This commit is contained in:
parent
aaf89cdea7
commit
7237c7be74
1 changed files with 11 additions and 0 deletions
|
@ -692,5 +692,16 @@ ActiveSupport::Notifications.subscribe "my.custom.event" do |name, started, fini
|
|||
end
|
||||
```
|
||||
|
||||
You also have the option to call instrument without passing a block. This lets you leverage the
|
||||
instrumentation infrastructure for other messaging uses.
|
||||
|
||||
```ruby
|
||||
ActiveSupport::Notifications.instrument "my.custom.event", this: :data
|
||||
|
||||
ActiveSupport::Notifications.subscribe "my.custom.event" do |name, started, finished, unique_id, data|
|
||||
puts data.inspect # {:this=>:data}
|
||||
end
|
||||
```
|
||||
|
||||
You should follow Rails conventions when defining your own events. The format is: `event.library`.
|
||||
If your application is sending Tweets, you should create an event named `tweet.twitter`.
|
||||
|
|
Loading…
Reference in a new issue