lib/sidekiq/prometheus/exporter/standard.rb in sidekiq-prometheus-exporter-0.1.17 vs lib/sidekiq/prometheus/exporter/standard.rb in sidekiq-prometheus-exporter-0.2.0
- old
+ new
@@ -9,11 +9,11 @@
class Standard
TEMPLATE = ERB.new(File.read(File.expand_path('templates/standard.erb', __dir__)))
QueueStats = Struct.new(:name, :size, :latency)
QueueWorkersStats = Struct.new(:total_workers, :busy_workers, :processes)
- WorkersStats = Struct.new(:total_workers, :by_queue)
+ WorkersStats = Struct.new(:total_workers, :by_queue, :by_host)
def self.available?
true
end
@@ -35,13 +35,16 @@
QueueStats.new(queue.name, queue.size, queue.latency)
end
end
def workers_stats
- workers_stats = WorkersStats.new(0, {})
+ workers_stats = WorkersStats.new(0, {}, {})
Sidekiq::ProcessSet.new.each_with_object(workers_stats) do |process, stats|
stats.total_workers += process['concurrency'].to_i
+
+ stats.by_host[process['hostname']] ||= Hash.new(0)
+ stats.by_host[process['hostname']][process['quiet']] += 1
process['queues'].each do |queue|
stats.by_queue[queue] ||= QueueWorkersStats.new(0, 0, 0)
stats.by_queue[queue].processes += 1
stats.by_queue[queue].busy_workers += process['busy'].to_i