Class: PrometheusExporter::Server::DelayedJobCollector
- Inherits:
-
TypeCollector
- Object
- TypeCollector
- PrometheusExporter::Server::DelayedJobCollector
- Defined in:
- lib/prometheus_exporter/server/delayed_job_collector.rb
Instance Method Summary collapse
- #collect(obj) ⇒ Object
-
#initialize ⇒ DelayedJobCollector
constructor
A new instance of DelayedJobCollector.
- #metrics ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize ⇒ DelayedJobCollector
Returns a new instance of DelayedJobCollector.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/prometheus_exporter/server/delayed_job_collector.rb', line 5 def initialize @delayed_jobs_total = nil @delayed_job_duration_seconds = nil @delayed_job_latency_seconds_total = nil @delayed_jobs_total = nil @delayed_failed_jobs_total = nil @delayed_jobs_max_attempts_reached_total = nil @delayed_job_duration_seconds_summary = nil @delayed_job_attempts_summary = nil @delayed_jobs_enqueued = nil @delayed_jobs_pending = nil end |
Instance Method Details
#collect(obj) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/prometheus_exporter/server/delayed_job_collector.rb', line 22 def collect(obj) custom_labels = obj["custom_labels"] || {} gauge_labels = { queue_name: obj["queue_name"] }.merge(custom_labels) counter_labels = gauge_labels.merge(job_name: obj["name"]) ensure_delayed_job_metrics @delayed_job_duration_seconds.observe(obj["duration"], counter_labels) @delayed_job_latency_seconds_total.observe(obj["latency"], counter_labels) @delayed_jobs_total.observe(1, counter_labels) @delayed_failed_jobs_total.observe(1, counter_labels) if !obj["success"] if obj["attempts"] >= obj["max_attempts"] @delayed_jobs_max_attempts_reached_total.observe(1, counter_labels) end @delayed_job_duration_seconds_summary.observe(obj["duration"], counter_labels) if obj["success"] @delayed_job_duration_seconds_summary.observe( obj["duration"], counter_labels.merge(status: "success"), ) end if !obj["success"] @delayed_job_duration_seconds_summary.observe( obj["duration"], counter_labels.merge(status: "failed"), ) end @delayed_job_attempts_summary.observe(obj["attempts"], counter_labels) if obj["success"] @delayed_jobs_enqueued.observe(obj["enqueued"], gauge_labels) @delayed_jobs_pending.observe(obj["pending"], gauge_labels) end |
#metrics ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/prometheus_exporter/server/delayed_job_collector.rb', line 53 def metrics if @delayed_jobs_total [ @delayed_job_duration_seconds, @delayed_job_latency_seconds_total, @delayed_jobs_total, @delayed_failed_jobs_total, @delayed_jobs_max_attempts_reached_total, @delayed_job_duration_seconds_summary, @delayed_job_attempts_summary, @delayed_jobs_enqueued, @delayed_jobs_pending, ] else [] end end |
#type ⇒ Object
18 19 20 |
# File 'lib/prometheus_exporter/server/delayed_job_collector.rb', line 18 def type "delayed_job" end |