Class: Phlex::Reactive::APM::Adapter

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

Overview

The adapter contract (issue #207). A custom APM integration need only be an object responding to these two methods — it does NOT have to subclass this; the class documents the interface and gives the built-in vendor adapters a shared home for the small helpers they all use.

record_action(payload, duration_ms)
payload is the name-only action/defer event payload
({ component:, action:, outcome: } — action:/nil for defer). Name the
APM transaction and tag the outcome. Called on EVERY reactive action.

record_error(error, payload)
error is the raised exception; payload is the same name-only hash. Report
the exception to the tracker WITH component/action tags. Called only on a
previously-uncaught action-body error (a 500), just before the re-raise.

A built-in adapter also answers .available? (a runtime defined?(SDK) probe) so the resolver can no-op when the SDK isn't loaded.

Direct Known Subclasses

Appsignal, Datadog, Sentry

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available?Boolean

Present but not enforced — a bare Adapter is not a usable APM. The vendor subclasses override all three.

Returns:

  • (Boolean)


37
# File 'lib/phlex/reactive/apm/adapter.rb', line 37

def self.available? = false

Instance Method Details

#record_action(_payload, _duration_ms) ⇒ Object



38
# File 'lib/phlex/reactive/apm/adapter.rb', line 38

def record_action(_payload, _duration_ms) = nil

#record_error(_error, _payload) ⇒ Object



39
# File 'lib/phlex/reactive/apm/adapter.rb', line 39

def record_error(_error, _payload) = nil

#transaction_name(payload) ⇒ Object

The APM transaction name for a payload: "Component#action", or just the component when there's no action (a defer event), or nil when there's no trusted component (an invalid_token event carries none).



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

def transaction_name(payload)
  component = payload[:component]
  return nil unless component

  action = payload[:action]
  action ? "#{component}##{action}" : component
end