Instrumenters 存储在线程本地变量中。
方法
- B
- F
- I
- N
- S
Attributes
| [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` 的事件的“句柄”。
必须在返回的对象上分别调用一次 start 和 finish。
可能的情况下,最好使用 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 = {}) 链接
给定一个块,通过测量执行时间和发布来对其进行 instrument。如果没有块,则仅通过 notifier 发送消息。请注意,即使传入的块发生错误,事件也会被发送。
来源: 显示 | 在 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