Sha256: 9c185cb2b344ab98afda2a09b2b871f8a83fe074572b068f6e13418f8a44c380
Contents?: true
Size: 1.81 KB
Versions: 2
Compression:
Stored size: 1.81 KB
Contents
# frozen_string_literal: true module PrometheusExporter::Server class ShoryukenCollector < TypeCollector def type "shoryuken" end def collect(obj) default_labels = { job_name: obj['name'] , queue_name: obj['queue'] } custom_labels = obj['custom_labels'] labels = custom_labels.nil? ? default_labels : default_labels.merge(custom_labels) ensure_shoryuken_metrics @shoryuken_job_duration_seconds.observe(obj["duration"], labels) @shoryuken_jobs_total.observe(1, labels) @shoryuken_restarted_jobs_total.observe(1, labels) if obj["shutdown"] @shoryuken_failed_jobs_total.observe(1, labels) if !obj["success"] && !obj["shutdown"] end def metrics if @shoryuken_jobs_total [ @shoryuken_job_duration_seconds, @shoryuken_jobs_total, @shoryuken_restarted_jobs_total, @shoryuken_failed_jobs_total, ] else [] end end protected def ensure_shoryuken_metrics if !@shoryuken_jobs_total @shoryuken_job_duration_seconds = PrometheusExporter::Metric::Counter.new( "shoryuken_job_duration_seconds", "Total time spent in shoryuken jobs.") @shoryuken_jobs_total = PrometheusExporter::Metric::Counter.new( "shoryuken_jobs_total", "Total number of shoryuken jobs executed.") @shoryuken_restarted_jobs_total = PrometheusExporter::Metric::Counter.new( "shoryuken_restarted_jobs_total", "Total number of shoryuken jobs that we restarted because of a shoryuken shutdown.") @shoryuken_failed_jobs_total = PrometheusExporter::Metric::Counter.new( "shoryuken_failed_jobs_total", "Total number of failed shoryuken jobs.") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prometheus_exporter-0.5.1 | lib/prometheus_exporter/server/shoryuken_collector.rb |
prometheus_exporter-0.5.0 | lib/prometheus_exporter/server/shoryuken_collector.rb |