Class: JetstreamBridge::ConsumerMiddleware::LoggingMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/jetstream_bridge/consumer/middleware.rb

Overview

Logging middleware for consumer message processing

Examples:

consumer.use(JetstreamBridge::Consumer::LoggingMiddleware.new)

Instance Method Summary collapse

Instance Method Details

#call(event) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/jetstream_bridge/consumer/middleware.rb', line 54

def call(event)
  start = Time.now
  Logging.info("Processing event #{event.event_id} (#{event.type})", tag: 'Consumer')
  yield
  duration = Time.now - start
  Logging.info("Completed event #{event.event_id} in #{duration.round(3)}s", tag: 'Consumer')
rescue StandardError => e
  Logging.error("Failed event #{event.event_id}: #{e.message}", tag: 'Consumer')
  raise
end