Class: Phlex::Reactive::APM::Appsignal

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

Overview

AppSignal adapter (issue #207). Activates only when ::Appsignal is loaded — never a gemspec dependency. Names the current transaction Component#action (so reactive traffic stops rolling into one ActionsController#create blob) and tags component/action/outcome; reports an action-body error with those tags.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Adapter

#transaction_name

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


11
# File 'lib/phlex/reactive/apm/appsignal.rb', line 11

def self.available? = defined?(::Appsignal) ? true : false

Instance Method Details

#record_action(payload, _duration_ms) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/phlex/reactive/apm/appsignal.rb', line 13

def record_action(payload, _duration_ms)
  name = transaction_name(payload)
  return unless name

  ::Appsignal.set_action(name)
  ::Appsignal.add_tags(tags(payload))
end

#record_error(error, payload) ⇒ Object

Report the error with tags. AppSignal 4.x removed the positional tags/namespace args from set_error and requires the BLOCK form (set_error(error) { add_tags(...) }); 3.x accepts the positional hash. Branch on the method's arity so the adapter works on both majors without pinning a version — the capability-detection posture applied within a gem.



26
27
28
29
30
31
32
# File 'lib/phlex/reactive/apm/appsignal.rb', line 26

def record_error(error, payload)
  if set_error_takes_tags?
    ::Appsignal.set_error(error, tags(payload))
  else
    ::Appsignal.set_error(error) { ::Appsignal.add_tags(tags(payload)) }
  end
end