Class: Bidi2pdf::Notifications::Instrumenter

Inherits:
Object
  • Object
show all
Defined in:
lib/bidi2pdf/notifications/instrumenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInstrumenter

Returns a new instance of Instrumenter.



17
18
19
# File 'lib/bidi2pdf/notifications/instrumenter.rb', line 17

def initialize
  @id = SecureRandom.uuid
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'lib/bidi2pdf/notifications/instrumenter.rb', line 15

def id
  @id
end

Instance Method Details

#notify(name, payload) ⇒ Object

Raises:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bidi2pdf/notifications/instrumenter.rb', line 21

def notify(name, payload, &)
  event = create_event(name, payload)
  result = nil
  begin
    result = event.record(&)
  rescue Exception => e
  end

  subscriber_exceptions = notify_subscribers(name, event)

  raise Bidi2pdf::NotificationsError.new(subscriber_exceptions), cause: subscriber_exceptions.first if subscriber_exceptions.any?
  raise e if e

  result
end