Sha256: fa179532bdadc811961aebdbb9837510193456860fafb664d525513259f7ace6

Contents?: true

Size: 1017 Bytes

Versions: 6

Compression:

Stored size: 1017 Bytes

Contents

# frozen_string_literal: true

require "active_support/subscriber"

module SidekiqPublisher
  module MetricsReporter
    class Subscriber < ActiveSupport::Subscriber
      private

      def count(metric, value)
        SidekiqPublisher.metrics_reporter&.try(:count, metric, value) unless value.nil?
      end
    end

    class PublisherSubscriber < Subscriber
      def enqueue_batch(event)
        count("sidekiq_publisher.published", event.payload[:published_count])
      end

      attach_to "publisher.sidekiq_publisher"
    end

    class JobSubscriber < Subscriber
      def purge(event)
        count("sidekiq_publisher.purged", event.payload[:purged_count])
      end

      attach_to "job.sidekiq_publisher"
    end

    class UnpublishedSubscriber < Subscriber
      def unpublished(event)
        SidekiqPublisher.metrics_reporter&.
          try(:gauge, "sidekiq_publisher.unpublished_count", event.payload[:unpublished_count])
      end

      attach_to "reporter.sidekiq_publisher"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sidekiq_publisher-1.8.0 lib/sidekiq_publisher/metrics_reporter.rb
sidekiq_publisher-1.8.0.rc0 lib/sidekiq_publisher/metrics_reporter.rb
sidekiq_publisher-1.7.1 lib/sidekiq_publisher/metrics_reporter.rb
sidekiq_publisher-1.7.0 lib/sidekiq_publisher/metrics_reporter.rb
sidekiq_publisher-1.7.0.rc1 lib/sidekiq_publisher/metrics_reporter.rb
sidekiq_publisher-1.7.0.rc0 lib/sidekiq_publisher/metrics_reporter.rb