class PrometheusExporter::Server::HutchCollector
Public Class Methods
new()
click to toggle source
# File lib/prometheus_exporter/server/hutch_collector.rb, line 5 def initialize @hutch_jobs_total = nil @hutch_job_duration_seconds = nil @hutch_jobs_total = nil @hutch_failed_jobs_total = nil end
Public Instance Methods
collect(obj)
click to toggle source
# File lib/prometheus_exporter/server/hutch_collector.rb, line 16 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_hutch_metrics @hutch_job_duration_seconds.observe(obj["duration"], labels) @hutch_jobs_total.observe(1, labels) @hutch_failed_jobs_total.observe(1, labels) if !obj["success"] end
metrics()
click to toggle source
# File lib/prometheus_exporter/server/hutch_collector.rb, line 27 def metrics if @hutch_jobs_total [@hutch_job_duration_seconds, @hutch_jobs_total, @hutch_failed_jobs_total] else [] end end
type()
click to toggle source
# File lib/prometheus_exporter/server/hutch_collector.rb, line 12 def type "hutch" end
Protected Instance Methods
ensure_hutch_metrics()
click to toggle source
# File lib/prometheus_exporter/server/hutch_collector.rb, line 37 def ensure_hutch_metrics if !@hutch_jobs_total @hutch_job_duration_seconds = PrometheusExporter::Metric::Counter.new( "hutch_job_duration_seconds", "Total time spent in hutch jobs.") @hutch_jobs_total = PrometheusExporter::Metric::Counter.new( "hutch_jobs_total", "Total number of hutch jobs executed.") @hutch_failed_jobs_total = PrometheusExporter::Metric::Counter.new( "hutch_failed_jobs_total", "Total number failed hutch jobs executed.") end end