Module: Pgbus::Metrics
- Defined in:
- lib/pgbus/metrics.rb,
lib/pgbus/metrics/backend.rb,
lib/pgbus/metrics/subscriber.rb,
lib/pgbus/metrics/backends/statsd.rb,
lib/pgbus/metrics/backends/prometheus.rb,
lib/pgbus/metrics/prometheus_exporter.rb
Overview
Backend-agnostic metrics adapter.
Pgbus emits a family of pgbus.* ActiveSupport::Notifications events;
Pgbus::Instrumentation is the single source of truth for the catalog. The
AppSignal integration is one consumer of those
events; this namespace is a second, vendor-neutral consumer that forwards the
same event→metric mapping to a configurable backend so teams on Prometheus,
Datadog, or plain StatsD get metrics without hand-writing subscribers.
Opt in via config.metrics_backend = :prometheus | :statsd | <Backend>. The
default is nil, which installs no subscription (zero overhead). Installation
happens from the engine, mirroring the AppSignal initializer.
Defined Under Namespace
Modules: Backends, Subscriber Classes: Backend, PrometheusExporter
Class Method Summary collapse
-
.resolve_backend(value) ⇒ Object
Coerce a configuration value into a concrete Backend instance.
Class Method Details
.resolve_backend(value) ⇒ Object
Coerce a configuration value into a concrete Backend instance.
nil -> Backend::Null (no-op)
:prometheus -> Backends::Prometheus
:statsd -> Backends::Statsd (host/port from configuration)
Backend inst -> returned unchanged
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pgbus/metrics.rb', line 25 def resolve_backend(value) case value when nil Backend::Null.new when :prometheus Backends::Prometheus.new when :statsd config = Pgbus.configuration Backends::Statsd.new(host: config.statsd_host, port: config.statsd_port) when Backend value else raise ArgumentError, "metrics_backend must be nil, :prometheus, :statsd, or a " \ "Pgbus::Metrics::Backend instance (got #{value.inspect})" end end |