跳到內容 跳到搜尋

Handle 用於記錄事件的開始和結束時間。

startfinish 兩個方法都必須各呼叫一次。

如果可能,最好使用區塊形式: ActiveSupport::Notifications.instrumentHandle 是一種底層 API,供無法使用區塊形式的情況使用。

handle = ActiveSupport::Notifications.instrumenter.build_handle("my.event", {})
begin
  handle.start
  # work to be instrumented
ensure
  handle.finish
end
方法
F
S

執行個體公用方法

finish()

# File activesupport/lib/active_support/notifications/fanout.rb, line 249
def finish
  finish_with_values(@name, @id, @payload)
end

start()

# File activesupport/lib/active_support/notifications/fanout.rb, line 240
def start
  ensure_state! :initialized
  @state = :started

  iterate_guarding_exceptions(@groups) do |group|
    group.start(@name, @id, @payload)
  end
end