Class: Exceptify::DatadogNotifier

Inherits:
BaseNotifier show all
Defined in:
lib/exceptify/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.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
# File 'lib/exceptify/datadog_notifier.rb', line 10

def initialize(options)
  super
  @client = options[:client]
  raise ArgumentError, "You must provide 'client' option" unless @client

  @default_options = options
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



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

def client
  @client
end

#default_optionsObject (readonly)

Returns the value of attribute default_options.



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

def default_options
  @default_options
end

Instance Method Details

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



18
19
20
21
22
# File 'lib/exceptify/datadog_notifier.rb', line 18

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

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



24
25
26
27
28
29
# File 'lib/exceptify/datadog_notifier.rb', line 24

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