Sha256: 57fb09a4018f4780fe44bd79b780dd9febb9b717531ef1368a6ecb02e8e8e0aa
Contents?: true
Size: 1.28 KB
Versions: 8
Compression:
Stored size: 1.28 KB
Contents
module PrometheusExporter::Server class SidekiqCollector < TypeCollector def type "sidekiq" end 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 @sidekiq_job_duration_seconds.observe(obj["duration"], labels) @sidekiq_jobs_total.observe(1, labels) @sidekiq_failed_jobs_total.observe(1, labels) if !obj["success"] end def metrics if @sidekiq_jobs_total [@sidekiq_job_duration_seconds, @sidekiq_jobs_total, @sidekiq_failed_jobs_total] else [] end end protected def ensure_sidekiq_metrics if !@sidekiq_jobs_total @sidekiq_job_duration_seconds = PrometheusExporter::Metric::Counter.new( "sidekiq_job_duration_seconds", "Total time spent in sidekiq jobs.") @sidekiq_jobs_total = PrometheusExporter::Metric::Counter.new( "sidekiq_jobs_total", "Total number of sidekiq jobs executed.") @sidekiq_failed_jobs_total = PrometheusExporter::Metric::Counter.new( "sidekiq_failed_jobs_total", "Total number failed sidekiq jobs executed.") end end end end
Version data entries
8 entries across 8 versions & 1 rubygems