Class: Bigcommerce::Prometheus::TypeCollectors::Resque
- Inherits:
-
Base
- Object
- PrometheusExporter::Server::TypeCollector
- Base
- Bigcommerce::Prometheus::TypeCollectors::Resque
- Defined in:
- lib/bigcommerce/prometheus/type_collectors/resque.rb
Overview
Collect resque data from collectors and parse them into metrics
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#build_metrics ⇒ Hash
Initialize the collector.
-
#collect_metrics(data:, labels: {}) ⇒ Object
Collect resque metrics from input data.
Methods inherited from Base
#collect, #initialize, #metric, #metrics
Constructor Details
This class inherits a constructor from Bigcommerce::Prometheus::TypeCollectors::Base
Instance Method Details
#build_metrics ⇒ Hash
Initialize the collector
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bigcommerce/prometheus/type_collectors/resque.rb', line 30 def build_metrics { workers_total: PrometheusExporter::Metric::Gauge.new('resque_workers_total', 'Number of active workers'), jobs_failed_total: PrometheusExporter::Metric::Gauge.new('jobs_failed_total', 'Number of failed jobs'), jobs_pending_total: PrometheusExporter::Metric::Gauge.new('jobs_pending_total', 'Number of pending jobs'), jobs_processed_total: PrometheusExporter::Metric::Gauge.new('jobs_processed_total', 'Number of processed jobs'), queues_total: PrometheusExporter::Metric::Gauge.new('queues_total', 'Number of total queues'), queue_sizes: PrometheusExporter::Metric::Gauge.new('queue_sizes', 'Size of each queue') } end |
#collect_metrics(data:, labels: {}) ⇒ Object
Collect resque metrics from input data
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bigcommerce/prometheus/type_collectors/resque.rb', line 44 def collect_metrics(data:, labels: {}) metric(:workers_total).observe(data['workers_total'], labels) metric(:jobs_failed_total).observe(data['jobs_failed_total'], labels) metric(:jobs_pending_total).observe(data['jobs_pending_total'], labels) metric(:jobs_processed_total).observe(data['jobs_processed_total'], labels) metric(:queues_total).observe(data['queues_total'], labels) data['queues'].each do |name, size| metric(:queue_sizes).observe(size, labels.merge(queue: name)) end end |