From 6f053b6ee58de90740afa9edd138a61414fa120a Mon Sep 17 00:00:00 2001 From: Andrew Pepler Date: Thu, 10 Oct 2024 16:32:03 +0100 Subject: [PATCH] Use custom config --- config/initializers/prometheus_exporter.rb | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/config/initializers/prometheus_exporter.rb b/config/initializers/prometheus_exporter.rb index 4b842d84..206cacec 100644 --- a/config/initializers/prometheus_exporter.rb +++ b/config/initializers/prometheus_exporter.rb @@ -1,2 +1,24 @@ -require "govuk_app_config/govuk_prometheus_exporter" -GovukPrometheusExporter.configure +unless Rails.env.test? || Rails.env.development? + require "prometheus_exporter/middleware" + require "prometheus_exporter/instrumentation" + + # This reports stats per request like HTTP status and timings + Rails.application.middleware.unshift PrometheusExporter::Middleware + # this reports basic process stats like RSS and GC info + PrometheusExporter::Instrumentation::Process.start(type: "master") + + if defined?(Sidekiq) + Sidekiq.configure_server do |config| + config.server_middleware do |chain| + chain.add PrometheusExporter::Instrumentation::Sidekiq + end + config.death_handlers << PrometheusExporter::Instrumentation::Sidekiq.death_handler + config.on :startup do + PrometheusExporter::Instrumentation::Process.start(type: "sidekiq") + PrometheusExporter::Instrumentation::SidekiqProcess.start + PrometheusExporter::Instrumentation::SidekiqQueue.start + PrometheusExporter::Instrumentation::SidekiqStats.start + end + end + end +end