Instrumentation 儲存在執行緒本機中。
方法
- 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