Class: Bigcommerce::Prometheus::TypeCollectors::Resque
- Inherits:
-
PrometheusExporter::Server::TypeCollector
- Object
- PrometheusExporter::Server::TypeCollector
- 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 Method Summary collapse
-
#collect(obj) ⇒ Object
Collect resque metrics from input data.
-
#initialize ⇒ Resque
constructor
Initialize the collector.
- #metrics ⇒ Array
- #type ⇒ String
Constructor Details
#initialize ⇒ Resque
Initialize the collector
28 29 30 31 32 33 34 35 |
# File 'lib/bigcommerce/prometheus/type_collectors/resque.rb', line 28 def initialize @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 |
Instance Method Details
#collect(obj) ⇒ Object
Collect resque metrics from input data
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/bigcommerce/prometheus/type_collectors/resque.rb', line 63 def collect(obj) default_labels = { environment: obj['environment'] } custom_labels = obj['custom_labels'] labels = custom_labels.nil? ? default_labels : default_labels.merge(custom_labels) @workers_total.observe(obj['workers_total'], labels) @jobs_failed_total.observe(obj['jobs_failed_total'], labels) @jobs_pending_total.observe(obj['jobs_pending_total'], labels) @jobs_processed_total.observe(obj['jobs_processed_total'], labels) @queues_total.observe(obj['queues_total'], labels) obj['queues'].each do |name, size| @queue_sizes.observe(size, labels.merge(queue: name)) end end |
#metrics ⇒ Array
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/bigcommerce/prometheus/type_collectors/resque.rb', line 47 def metrics return [] unless @workers_total [ @workers_total, @jobs_failed_total, @jobs_pending_total, @jobs_processed_total, @queues_total, @queue_sizes ] end |
#type ⇒ String
40 41 42 |
# File 'lib/bigcommerce/prometheus/type_collectors/resque.rb', line 40 def type 'resque' end |