Class: Phlex::Reactive::APM::Datadog

Inherits:
Adapter
  • Object
show all
Defined in:
lib/phlex/reactive/apm/datadog.rb

Overview

Datadog adapter (issue #207, dd-trace-rb). Activates only when ::Datadog::Tracing is loaded. Renames the ACTIVE span Component#action

  • tags it, so the reactive action shows as its own resource in the trace; marks the active span errored on an action-body crash. No-ops with no active span (never opens one itself — that's the app's tracer's job).

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Adapter

#transaction_name

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/phlex/reactive/apm/datadog.rb', line 12

def self.available?
  return false unless defined?(::Datadog::Tracing)

  ::Datadog.respond_to?(:configuration)
end

Instance Method Details

#record_action(payload, _duration_ms) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/phlex/reactive/apm/datadog.rb', line 18

def record_action(payload, _duration_ms)
  span = active_span
  return unless span

  name = transaction_name(payload)
  span.resource = name if name
  span.set_tag("reactive.component", payload[:component]) if payload[:component]
  span.set_tag("reactive.action", payload[:action]) if payload[:action]
  span.set_tag("reactive.outcome", payload[:outcome].to_s) if payload[:outcome]
end

#record_error(error, payload) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/phlex/reactive/apm/datadog.rb', line 29

def record_error(error, payload)
  span = active_span
  return unless span

  span.set_error(error)
  span.set_tag("reactive.component", payload[:component]) if payload[:component]
  span.set_tag("reactive.action", payload[:action]) if payload[:action]
end