Sha256: 758b33d0ac928ce035cd888f88d6dd24efaf78e33dcf00522df4304ed4c84662

Contents?: true

Size: 629 Bytes

Versions: 7

Compression:

Stored size: 629 Bytes

Contents

module NewrelicSidekiqMetrics
  class Recorder
    attr_reader :metrics

    def initialize
      @metrics = NewrelicSidekiqMetrics.used_metrics
    end

    def call
      metrics.each { |m| record_metric(m) }
    end

    private

    def stats
      @stats ||= Sidekiq::Stats.new
    end

    def get_stat(name)
      return 0 if NewrelicSidekiqMetrics.inline_sidekiq?

      stats.public_send(name)
    end

    def record_metric(name)
      NewRelic::Agent.record_metric(metric_full_name(name), get_stat(name))
    end

    def metric_full_name(name)
      File.join(METRIC_PREFIX, METRIC_MAP.fetch(name))
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
newrelic-sidekiq-metrics-1.6.2 lib/newrelic_sidekiq_metrics/recorder.rb
newrelic-sidekiq-metrics-1.6.1 lib/newrelic_sidekiq_metrics/recorder.rb
newrelic-sidekiq-metrics-1.6.0 lib/newrelic_sidekiq_metrics/recorder.rb
newrelic-sidekiq-metrics-1.5.2 lib/newrelic_sidekiq_metrics/recorder.rb
newrelic-sidekiq-metrics-1.5.1 lib/newrelic_sidekiq_metrics/recorder.rb
newrelic-sidekiq-metrics-1.5.0 lib/newrelic_sidekiq_metrics/recorder.rb
newrelic-sidekiq-metrics-1.4.1 lib/newrelic_sidekiq_metrics/recorder.rb