class PrometheusExporter::Instrumentation::Resque
Public Class Methods
start(client: nil, frequency: 30)
click to toggle source
# File lib/prometheus_exporter/instrumentation/resque.rb, line 6 def self.start(client: nil, frequency: 30) resque_collector = new client ||= PrometheusExporter::Client.default Thread.new do while true begin client.send_json(resque_collector.collect) rescue => e client.logger.error("Prometheus Exporter Failed To Collect Resque Stats #{e}") ensure sleep frequency end end end end
Public Instance Methods
collect()
click to toggle source
# File lib/prometheus_exporter/instrumentation/resque.rb, line 22 def collect metric = {} metric[:type] = "resque" collect_resque_stats(metric) metric end
collect_resque_stats(metric)
click to toggle source
# File lib/prometheus_exporter/instrumentation/resque.rb, line 29 def collect_resque_stats(metric) info = ::Resque.info metric[:processed_jobs_total] = info[:processed] metric[:failed_jobs_total] = info[:failed] metric[:pending_jobs_total] = info[:pending] metric[:queues_total] = info[:queues] metric[:worker_total] = info[:workers] metric[:working_total] = info[:working] end