class PrometheusExporter::Server::ShoryukenCollector
Public Class Methods
new()
click to toggle source
# File lib/prometheus_exporter/server/shoryuken_collector.rb, line 6 def initialize @shoryuken_jobs_total = nil @shoryuken_job_duration_seconds = nil @shoryuken_jobs_total = nil @shoryuken_restarted_jobs_total = nil @shoryuken_failed_jobs_total = nil end
Public Instance Methods
collect(obj)
click to toggle source
# File lib/prometheus_exporter/server/shoryuken_collector.rb, line 18 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
metrics()
click to toggle source
# File lib/prometheus_exporter/server/shoryuken_collector.rb, line 30 def metrics if @shoryuken_jobs_total [ @shoryuken_job_duration_seconds, @shoryuken_jobs_total, @shoryuken_restarted_jobs_total, @shoryuken_failed_jobs_total, ] else [] end end
type()
click to toggle source
# File lib/prometheus_exporter/server/shoryuken_collector.rb, line 14 def type "shoryuken" end
Protected Instance Methods
ensure_shoryuken_metrics()
click to toggle source
# File lib/prometheus_exporter/server/shoryuken_collector.rb, line 45 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