diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2019-03-22 14:02:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-22 14:02:38 -0400 |
commit | 75f19b5deb02410ea41a934d3bc822cec106fa6c (patch) | |
tree | 25de7f6604622c82d66d5016a510a96fc769ef2a /guides/source | |
parent | f40860800c231ecd1daef6cf6b5a8a8eda76478d (diff) | |
parent | 7237c7be74b09cd951ff000afb4087313e5c0025 (diff) | |
download | rails-75f19b5deb02410ea41a934d3bc822cec106fa6c.tar.gz rails-75f19b5deb02410ea41a934d3bc822cec106fa6c.tar.bz2 rails-75f19b5deb02410ea41a934d3bc822cec106fa6c.zip |
Merge pull request #35705 from alimi/instrumenter-block-optional
Update AS::Notifications::Instrumenter#instrument
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/active_support_instrumentation.md | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/guides/source/active_support_instrumentation.md b/guides/source/active_support_instrumentation.md index 89e0e3afa8..d7dbc5cea8 100644 --- a/guides/source/active_support_instrumentation.md +++ b/guides/source/active_support_instrumentation.md @@ -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`. |