跳至内容 跳至搜索

一个 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 250
def finish
  finish_with_values(@name, @id, @payload)
end

start()

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

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