Sha256: c5be8c3b4e6722431f332d6cba86da9fcb35f28fc2a3d13a1c7fc8c3c8ec941d
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true module PrometheusExporter::Instrumentation class SidekiqProcess def self.start(client: nil, frequency: 30) client ||= PrometheusExporter::Client.default sidekiq_process_collector = new Thread.new do loop do begin client.send_json(sidekiq_process_collector.collect) rescue StandardError => e STDERR.puts("Prometheus Exporter Failed To Collect Sidekiq Processes metrics #{e}") ensure sleep frequency end end end end def initialize @pid = ::Process.pid @hostname = Socket.gethostname end def collect { type: 'sidekiq_process', process: collect_stats } end def collect_stats process = current_process return {} unless process { busy: process['busy'], concurrency: process['concurrency'], labels: { labels: process['labels'].sort.join(','), queues: process['queues'].sort.join(','), quiet: process['quiet'], tag: process['tag'], hostname: process['hostname'], identity: process['identity'], } } end def current_process ::Sidekiq::ProcessSet.new.find do |sp| sp['hostname'] == @hostname && sp['pid'] == @pid end end end end
Version data entries
3 entries across 3 versions & 1 rubygems