Sha256: fee0ae456c7b4ea3029335274580931cfea5d71086086fd86275137f4ff7bc81

Contents?: true

Size: 659 Bytes

Versions: 3

Compression:

Stored size: 659 Bytes

Contents

# frozen_string_literal: true

# Patch to get metrics from Rabbit::Receiving::Job
# https://github.com/umbrellio/rabbit_messaging/blob/master/lib/rabbit/receiving/job.rb
module Yabeda
  module RabbitMessaging
    module JobPatch
      def perform(message, arguments)
        duration = Benchmark.realtime { super(message, arguments) }
      ensure
        labels = arguments.slice(:exchange, :routing_key)

        if labels.present?
          labels[:success] = duration.present?

          Yabeda.rabbit_messages_total.increment(labels)
          Yabeda.rabbit_messages_duration.measure(labels, duration) if duration
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yabeda-rabbit_messaging-0.0.3 lib/yabeda/rabbit_messaging/job_patch.rb
yabeda-rabbit_messaging-0.0.2 lib/yabeda/rabbit_messaging/job_patch.rb
yabeda-rabbit_messaging-0.0.1 lib/yabeda/rabbit_messaging/job_patch.rb