設定器儲存在執行緒當地。
方法
- 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
的事件的「控制項」。
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 = {}) 連結
給定一個區塊,透過測量執行和發布的時間,對它進行設定。不帶區塊,則透過通知程式傳送一個訊息。請注意,即使在傳入區塊中發生錯誤,事件仍會被傳送出去。
來源: 顯示 | 在 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