- 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.
48 lines
1.1 KiB
Ruby
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
|