Class: ExceptionNotifier::DatadogNotifier

Inherits:
BaseNotifier show all
Defined in:
lib/exception_notifier/datadog_notifier.rb

Defined Under Namespace

Classes: DatadogExceptionEvent

Instance Attribute Summary collapse

Attributes inherited from BaseNotifier

#base_options

Instance Method Summary collapse

Methods inherited from BaseNotifier

#_post_callback, #_pre_callback, #send_notice

Constructor Details

#initialize(options) ⇒ DatadogNotifier

Returns a new instance of DatadogNotifier.



10
11
12
13
14
# File 'lib/exception_notifier/datadog_notifier.rb', line 10

def initialize(options)
  super
  @client = options.fetch(:client)
  @default_options = options
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/exception_notifier/datadog_notifier.rb', line 7

def client
  @client
end

#default_optionsObject (readonly)

Returns the value of attribute default_options.



7
8
9
# File 'lib/exception_notifier/datadog_notifier.rb', line 7

def default_options
  @default_options
end

Instance Method Details

#call(exception, options = {}) ⇒ Object



16
17
18
19
20
# File 'lib/exception_notifier/datadog_notifier.rb', line 16

def call(exception, options = {})
  client.emit_event(
    datadog_event(exception, options)
  )
end

#datadog_event(exception, options = {}) ⇒ Object



22
23
24
25
26
27
# File 'lib/exception_notifier/datadog_notifier.rb', line 22

def datadog_event(exception, options = {})
  DatadogExceptionEvent.new(
    exception,
    options.reverse_merge(default_options)
  ).event
end