Sha256: 03a134f46335c19fcef400ef8fb35af741f75c1fdf61592674e2b40fcc4754d4
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module PrometheusExporter::Server class SidekiqStatsCollector < TypeCollector MAX_METRIC_AGE = 60 SIDEKIQ_STATS_GAUGES = { 'dead_size' => 'Size of dead the queue', 'enqueued' => 'Number of enqueued jobs', 'failed' => 'Number of failed jobs', 'processed' => 'Total number of processed jobs', 'processes_size' => 'Number of processes', 'retry_size' => 'Size of the retries queue', 'scheduled_size' => 'Size of the scheduled queue', 'workers_size' => 'Number of jobs actively being processed', }.freeze attr_reader :sidekiq_metrics, :gauges def initialize @sidekiq_metrics = MetricsContainer.new(ttl: MAX_METRIC_AGE) @gauges = {} end def type 'sidekiq_stats' end def metrics SIDEKIQ_STATS_GAUGES.each_key { |name| gauges[name]&.reset! } sidekiq_metrics.map do |metric| SIDEKIQ_STATS_GAUGES.map do |name, help| if (value = metric['stats'][name]) gauge = gauges[name] ||= PrometheusExporter::Metric::Gauge.new("sidekiq_stats_#{name}", help) gauge.observe(value) end end end gauges.values end def collect(object) @sidekiq_metrics << object end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prometheus_exporter-2.1.1 | lib/prometheus_exporter/server/sidekiq_stats_collector.rb |
prometheus_exporter-2.1.0 | lib/prometheus_exporter/server/sidekiq_stats_collector.rb |