Class: PrometheusExporter::Server::HutchCollector
- Inherits:
-
TypeCollector
- Object
- TypeCollector
- PrometheusExporter::Server::HutchCollector
- Defined in:
- lib/prometheus_exporter/server/hutch_collector.rb
Instance Method Summary collapse
- #collect(obj) ⇒ Object
-
#initialize ⇒ HutchCollector
constructor
A new instance of HutchCollector.
- #metrics ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize ⇒ HutchCollector
Returns a new instance of HutchCollector.
5 6 7 8 9 10 |
# 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 |
Instance Method Details
#collect(obj) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# 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 ⇒ Object
27 28 29 30 31 32 33 |
# 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 ⇒ Object
12 13 14 |
# File 'lib/prometheus_exporter/server/hutch_collector.rb', line 12 def type "hutch" end |