Class: Lepus::Producers::Middlewares::Instrumentation
- Inherits:
-
Middleware
- Object
- Middleware
- Lepus::Producers::Middlewares::Instrumentation
- Defined in:
- lib/lepus/producers/middlewares/instrumentation.rb
Overview
A middleware that emits instrumentation events via Lepus.instrument.
Instance Method Summary collapse
- #call(message, app) ⇒ Object
-
#initialize(**opts) ⇒ Instrumentation
constructor
A new instance of Instrumentation.
Constructor Details
#initialize(**opts) ⇒ Instrumentation
Returns a new instance of Instrumentation.
10 11 12 13 |
# File 'lib/lepus/producers/middlewares/instrumentation.rb', line 10 def initialize(**opts) super @event_name = opts.fetch(:event_name, "publish") end |
Instance Method Details
#call(message, app) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/lepus/producers/middlewares/instrumentation.rb', line 15 def call(, app) exchange = .delivery_info&.exchange routing_key = .delivery_info&.routing_key Lepus.instrument(event_name, exchange: exchange, routing_key: routing_key, message: ) do app.call() end end |