lib/hallmonitor/monitored.rb in hallmonitor-1.0.0 vs lib/hallmonitor/monitored.rb in hallmonitor-1.1.0

- old
+ new

@@ -60,14 +60,14 @@ # Otherwise, a new {Hallmonitor::Event} will be created with the parameter # and emitted. # @param event [Mixed] The thing to emit, see method description # @yield [to_emit] The thing that's going to be emitted # @return nil - def emit(event = nil) + def emit(event = nil, tags: {}) to_emit = self unless event.nil? - to_emit = event.is_a?(Hallmonitor::Event) ? event : Hallmonitor::Event.new(event) + to_emit = event.is_a?(Hallmonitor::Event) ? event : Hallmonitor::Event.new(event, tags: tags) end # If we were given a block, then we want to execute that yield(to_emit) if block_given? @@ -78,11 +78,11 @@ # Executes and times a block of code and emits a {TimedEvent} # @note Will emit the timed event even if the block raises an error # @param name [String] The name of the event to emit # @yield [event] the event object that will be emitted # @return Whatever the block's return value is - def watch(name) - event = Hallmonitor::TimedEvent.new(name) + def watch(name, tags: {}) + event = Hallmonitor::TimedEvent.new(name, tags: tags) event.start = Time.now begin yield(event) ensure event.stop = Time.now