diff --git a/config/initializers/prometheus.rb b/config/initializers/prometheus.rb index e7a9245..93bfccc 100644 --- a/config/initializers/prometheus.rb +++ b/config/initializers/prometheus.rb @@ -1,4 +1,4 @@ -unless Rails.env.test? +if Rails.env.production? require 'prometheus_exporter/middleware' # This reports stats per request like HTTP status and timings diff --git a/config/puma.rb b/config/puma.rb index 58f7ea8..e36b88d 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -57,8 +57,10 @@ end on_worker_boot do ActiveRecord::Base.establish_connection if defined?(ActiveRecord) - require 'prometheus_exporter/instrumentation' - PrometheusExporter::Instrumentation::ActiveRecord.start(custom_labels: { type: 'puma_worker' }, config_labels: %i[database host]) - PrometheusExporter::Instrumentation::Puma.start - PrometheusExporter::Instrumentation::Process.start(type: 'web') + if Rails.env.production? + require 'prometheus_exporter/instrumentation' + PrometheusExporter::Instrumentation::ActiveRecord.start(custom_labels: { type: 'puma_worker' }, config_labels: %i[database host]) + PrometheusExporter::Instrumentation::Puma.start + PrometheusExporter::Instrumentation::Process.start(type: 'web') + end end