Class: PrometheusExporter::Server::SidekiqCollector
- Inherits:
-
TypeCollector
- Object
- TypeCollector
- PrometheusExporter::Server::SidekiqCollector
- Defined in:
- lib/prometheus_exporter/server/sidekiq_collector.rb
Instance Method Summary collapse
Instance Method Details
#collect(obj) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/prometheus_exporter/server/sidekiq_collector.rb', line 10 def collect(obj) default_labels = { job_name: obj['name'] } custom_labels = obj['custom_labels'] labels = custom_labels.nil? ? default_labels : default_labels.merge(custom_labels) ensure_sidekiq_metrics if obj["dead"] @sidekiq_dead_jobs_total.observe(1, labels) else @sidekiq_job_duration_seconds.observe(obj["duration"], labels) @sidekiq_jobs_total.observe(1, labels) @sidekiq_restarted_jobs_total.observe(1, labels) if obj["shutdown"] @sidekiq_failed_jobs_total.observe(1, labels) if !obj["success"] && !obj["shutdown"] end end |
#metrics ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/prometheus_exporter/server/sidekiq_collector.rb', line 26 def metrics if @sidekiq_jobs_total [ @sidekiq_job_duration_seconds, @sidekiq_jobs_total, @sidekiq_restarted_jobs_total, @sidekiq_failed_jobs_total, @sidekiq_dead_jobs_total, ] else [] end end |
#type ⇒ Object
6 7 8 |
# File 'lib/prometheus_exporter/server/sidekiq_collector.rb', line 6 def type "sidekiq" end |