Class: PrometheusExporter::Instrumentation::Resque
- Inherits:
-
Object
- Object
- PrometheusExporter::Instrumentation::Resque
- Defined in:
- lib/prometheus_exporter/instrumentation/resque.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.start(client: nil, frequency: 30) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# 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 |
Instance Method Details
#collect ⇒ Object
22 23 24 25 26 27 |
# 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) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/prometheus_exporter/instrumentation/resque.rb', line 29 def collect_resque_stats(metric) info = ::Resque.info metric[:processed_jobs] = info[:processed] metric[:failed_jobs] = info[:failed] metric[:pending_jobs] = info[:pending] metric[:queues] = info[:queues] metric[:worker] = info[:workers] metric[:working] = info[:working] end |