Method: Hallmonitor::Monitored#watch

Defined in:
lib/hallmonitor/monitored.rb

#watch(name, tags: {}) {|event| ... } ⇒ Object

Note:

Will emit the timed event even if the block raises an error

Executes and times a block of code and emits a TimedEvent

Parameters:

  • name (String)

    The name of the event to emit

Yields:

  • (event)

    the event object that will be emitted

Returns:

  • Whatever the block’s return value is



90
91
92
93
94
95
96
97
98
99
# File 'lib/hallmonitor/monitored.rb', line 90

def watch(name, tags: {})
  event = Hallmonitor::TimedEvent.new(name, tags: tags)
  event.start = Time.now
  begin
    yield(event)
  ensure
    event.stop = Time.now
    emit(event)
  end
end