Files
redux-scraper/app/lib/scraper/metrics/good_job_metrics_with_queues.rb
Dylan Knutson 13f078eb34 Add GoodJob metrics integration and update Prometheus configuration
- Introduced a new `GoodJobMetricsWithQueues` class for tracking GoodJob queue counts using Prometheus.
- Updated `application.rb` to include Prometheus exporter dependencies and configuration.
- Added a new `prometheus_exporter.yml` file to manage Prometheus settings across environments.
- Modified `puma.rb` to remove redundant Prometheus instrumentation code.
- Enabled eager loading in the development environment for better performance.
- Updated GoodJob initializer to start the new metrics tracking.

These changes enhance monitoring capabilities for job processing and improve application performance.
2025-01-04 07:23:08 +00:00

48 lines
1.1 KiB
Ruby

# typed: strict
class Scraper::Metrics::GoodJobMetricsWithQueues < PrometheusExporter::Instrumentation::PeriodicStats
extend T::Sig
sig do
params(
client: T.nilable(PrometheusExporter::Client),
frequency: Numeric,
).void
end
def self.start(client: nil, frequency: 5)
client ||= PrometheusExporter::Client.default
gauge =
T.cast(
client.register(
:gauge,
"good_job_queue_counts",
"GoodJob queue counts",
),
PrometheusExporter::Client::RemoteMetric,
)
worker_loop do
SCOPES.each do |scope|
GoodJob::Job
.send(scope)
.group(:queue_name, :job_class)
.count
.each do |(queue_name, job_class), count|
gauge.observe(
count,
{ queue_name: queue_name, job_class: job_class },
)
end
end
end
super
end
SCOPES = %i[all scheduled retried queued running finished succeeded discarded]
sig { params(client: PrometheusExporter::Client).void }
def collect(client)
end
end