Handle
用於記錄事件的開始和結束時間。
在可能的情況下,最好使用區塊形式: ActiveSupport::Notifications.instrument
。Handle
是低階 API,適用於無法使用區塊形式的情況。
handle = ActiveSupport::Notifications.instrumenter.build_handle("my.event", {})
begin
handle.start
# work to be instrumented
ensure
handle.finish
end
方法
執行個體公開方法
finish() 連結
來源: 顯示 | 在 GitHub 上
# File activesupport/lib/active_support/notifications/fanout.rb, line 253 def finish finish_with_values(@name, @id, @payload) end
start() 連結
來源: 顯示 | 在 GitHub 上
# File activesupport/lib/active_support/notifications/fanout.rb, line 244 def start ensure_state! :initialized @state = :started iterate_guarding_exceptions(@groups) do |group| group.start(@name, @id, @payload) end end