diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2019-05-10 15:16:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-10 15:16:49 -0400 |
commit | 36d145ca457d7f663517ac4096d8fae3da2491a9 (patch) | |
tree | 6d0ce4a59e1a68e0c28311eaf6d1d6f23f7266bd /guides/source | |
parent | 6394f9da6938d0dccfd8c95f10b2fb7ee98ab953 (diff) | |
parent | 93b652affbed41bce568a0fac4ca7b56aa3b691f (diff) | |
download | rails-36d145ca457d7f663517ac4096d8fae3da2491a9.tar.gz rails-36d145ca457d7f663517ac4096d8fae3da2491a9.tar.bz2 rails-36d145ca457d7f663517ac4096d8fae3da2491a9.zip |
Merge pull request #36184 from vishaltelangre/as-monotonic-timed-subscriber
Introduce ActiveSupport::Notifications.monotonic_subscribe
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/active_support_instrumentation.md | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/guides/source/active_support_instrumentation.md b/guides/source/active_support_instrumentation.md index 4868b00bbe..9f15e70da6 100644 --- a/guides/source/active_support_instrumentation.md +++ b/guides/source/active_support_instrumentation.md @@ -643,7 +643,16 @@ The block receives the following arguments: ```ruby ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, started, finished, unique_id, data| # your own custom stuff - Rails.logger.info "#{name} Received!" + Rails.logger.info "#{name} Received! (started: #{started}, finished: #{finished})" # process_action.action_controller Received (started: 2019-05-05 13:43:57 -0800, finished: 2019-05-05 13:43:58 -0800) +end +``` + +If you are concerned about the accuracy of `started` and `finished` to compute a precise elapsed time then use `ActiveSupport::Notifications.monotonic_subscribe`. The given block would receive the same arguments as above but the `started` and `finished` will have values with an accurate monotonic time instead of wall-clock time. + +```ruby +ActiveSupport::Notifications.monotonic_subscribe "process_action.action_controller" do |name, started, finished, unique_id, data| + # your own custom stuff + Rails.logger.info "#{name} Received! (started: #{started}, finished: #{finished})" # process_action.action_controller Received (started: 1560978.425334, finished: 1560979.429234) end ``` |