Module: Pgbus::Integrations::Appsignal::Subscriber
- Defined in:
- lib/pgbus/integrations/appsignal/subscriber.rb
Overview
Translates Pgbus::Instrumentation events into AppSignal transactions and custom metrics.
Job and event-handler events open a BACKGROUND_JOB transaction so they appear under AppSignal’s “Performance > Background jobs” view, with action ‘<JobClass>#perform` or `<HandlerClass>#handle`. All other events are reported as counters or distributions only.
All metric names are prefixed ‘pgbus_`. Tag keys avoid high-cardinality values (no msg_id, no event_id) so AppSignal’s metric storage stays efficient.
Class Method Summary collapse
Class Method Details
.install! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pgbus/integrations/appsignal/subscriber.rb', line 28 def install! return false if @installed @subscriptions = [ subscribe("pgbus.executor.execute") { |event| on_executor_execute(event) }, subscribe("pgbus.job_completed") { |event| on_job_completed(event) }, subscribe("pgbus.job_failed") { |event| on_job_failed(event) }, subscribe("pgbus.job_dead_lettered") { |event| on_job_dead_lettered(event) }, subscribe("pgbus.event_processed") { |event| on_event_processed(event) }, subscribe("pgbus.event_failed") { |event| on_event_failed(event) }, subscribe("pgbus.client.send_message") { |event| (event) }, subscribe("pgbus.client.send_batch") { |event| on_send_batch(event) }, subscribe("pgbus.client.read_batch") { |event| on_read_batch(event) }, subscribe("pgbus.stream.broadcast") { |event| on_stream_broadcast(event) }, subscribe("pgbus.outbox.publish") { |event| on_outbox_publish(event) }, subscribe("pgbus.recurring.enqueue") { |event| on_recurring_enqueue(event) }, subscribe("pgbus.worker.recycle") { |event| on_worker_recycle(event) } ] @installed = true end |
.installed? ⇒ Boolean
49 50 51 |
# File 'lib/pgbus/integrations/appsignal/subscriber.rb', line 49 def installed? @installed == true end |
.reset! ⇒ Object
53 54 55 56 57 |
# File 'lib/pgbus/integrations/appsignal/subscriber.rb', line 53 def reset! @subscriptions&.each { |s| ActiveSupport::Notifications.unsubscribe(s) } @subscriptions = [] @installed = false end |