仪器存储在本地线程中。
方法
- B
- F
- I
- N
- S
属性
[R] | id |
类公共方法
new(notifier) 链接
来源:显示 | 在 GitHub 上
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 12 def initialize(notifier) unless notifier.respond_to?(:build_handle) notifier = LegacyHandle::Wrapper.new(notifier) end @id = unique_id @notifier = notifier end
实例公共方法
build_handle(name, payload) 链接
返回给定name
和payload
的事件的“句柄”。
在可能的情况下,最好使用instrument
,它将记录事件的开始和结束,并正确处理任何异常。build_handle
是一个低级 API,适用于无法使用instrument
的情况。
来源:显示 | 在 GitHub 上
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 78 def build_handle(name, payload) @notifier.build_handle(name, @id, payload) end
finish(name, payload) 链接
发送带有name
和payload
的完成通知。
来源:显示 | 在 GitHub 上
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 92 def finish(name, payload) @notifier.finish name, @id, payload end
finish_with_state(listeners_state, name, payload) 链接
来源:显示 | 在 GitHub 上
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 96 def finish_with_state(listeners_state, name, payload) @notifier.finish name, @id, payload, listeners_state end
instrument(name, payload = {}) 链接
给定一个块,通过测量执行和发布该块所花费的时间来对其进行检测。如果没有块,只需通过通知程序发送一条消息。请注意,即使在传入块中发生错误,也会发送事件。
来源:显示 | 在 GitHub 上
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 54 def instrument(name, payload = {}) handle = build_handle(name, payload) handle.start begin yield payload if block_given? rescue Exception => e payload[:exception] = [e.class.name, e.message] payload[:exception_object] = e raise e ensure handle.finish end end
start(name, payload) 链接
使用 name
和 payload
发送一个开始通知。
来源:显示 | 在 GitHub 上
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 87 def start(name, payload) @notifier.start name, @id, payload end