Class: DatadogNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog_notifier.rb,
lib/datadog_notifier/version.rb

Overview

DatadogNotifier for custom error notification to datadog

Constant Summary collapse

VERSION =
"1.0.2"

Class Method Summary collapse

Class Method Details

.find_root_span(child_span) ⇒ Object



20
21
22
23
24
# File 'lib/datadog_notifier.rb', line 20

def self.find_root_span(child_span)
  current_span = child_span
  current_span = current_span.send(:parent) while current_span.send(:parent)
  current_span
end

.notify(exception, payload = {}) ⇒ Object



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

def self.notify(exception, payload = {})
  root_span = find_root_span(Datadog::Tracing.active_span)
  if exception.is_a?(String)
    exception = DatadogNotifierException.new exception
    exception.set_backtrace(payload.inspect)
  end
  root_span.set_error(exception)
  root_span.set_tag('custom_dd_notifier', true)
  root_span.set_tag('payload', payload.to_json) if payload.present?
end