class ActiveSupport::Notifications::Instrumenter

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/active_support/notifications/instrumenter.rbs

class ActiveSupport::Notifications::Instrumenter
  def build_handle: (String name, Hash payload) -> ActiveSupport::Notifications::Fanout::Handle
end

Instrumenters are stored in a thread local.

def build_handle(name, payload)

Experimental RBS support (using type sampling data from the type_fusion project).

def build_handle: (String name, controller | String | action | String | request | ActionDispatch::Request | params | id | String | controller | String | action | String | gem | String | version | String | headers | ActionDispatch::Http::Headers | format | Symbol | method | String | path | String payload) -> ActiveSupport::Notifications::Fanout::Handle

This signature was generated using 1 sample from 1 application.

See ActiveSupport::Notifications::Fanout::Handle.

+instrument+ isn't possible.
+build_handle+ is a low-level API intended for cases where using
start and finish of the event and correctly handle any exceptions.
Where possible, it's best to use #instrument, which will record the

#start and #finish must each be called exactly once on the returned object.

Returns a "handle" for an event with the given +name+ and +payload+.
def build_handle(name, payload)
  @notifier.build_handle(name, @id, payload)
end

def finish(name, payload)

Send a finish notification with +name+ and +payload+.
def finish(name, payload)
  @notifier.finish name, @id, payload
end

def finish_with_state(listeners_state, name, payload)

def finish_with_state(listeners_state, name, payload)
  @notifier.finish name, @id, payload, listeners_state
end

def initialize(notifier)

def initialize(notifier)
  unless notifier.respond_to?(:build_handle)
    notifier = LegacyHandle::Wrapper.new(notifier)
  end
  @id       = unique_id
  @notifier = notifier
end

def instrument(name, payload = {})

passed-in block.
notifier. Notice that events get sent even if an error occurs in the
and publish it. Without a block, simply send a message via the
Given a block, instrument it by measuring the time taken to execute
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

def new_event(name, payload = {}) # :nodoc:

:nodoc:
def new_event(name, payload = {}) # :nodoc:
  Event.new(name, nil, nil, @id, payload)
end

def start(name, payload)

Send a start notification with +name+ and +payload+.
def start(name, payload)
  @notifier.start name, @id, payload
end

def unique_id

def unique_id
  SecureRandom.hex(10)
end