Module: Lepus::Prometheus::Instrumentation::HandlerExtensions
- Defined in:
- lib/lepus/prometheus/instrumentation.rb
Overview
Tracks per-delivery outcomes and latency. Always emits a metric, even when the underlying consumer raises, so error rates are observable.
Instance Method Summary collapse
Instance Method Details
#process_delivery(delivery_info, metadata, payload) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lepus/prometheus/instrumentation.rb', line 13 def process_delivery(delivery_info, , payload) start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) result = nil error_class = nil begin result = super rescue => e error_class = e.class.name raise ensure Lepus::Prometheus.emit( :delivery, consumer: @consumer_class.name, queue: queue_name_for_metric, result: error_class ? "error" : result.to_s, error: error_class.to_s, duration: ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start ) end result end |