From 2383ab9454edfc195d63178152487cb026c80a4d Mon Sep 17 00:00:00 2001 From: f Date: Mon, 28 Sep 2020 19:38:53 -0300 Subject: [PATCH] =?UTF-8?q?iniciar=20prometheus=20solo=20en=20producci?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/initializers/prometheus.rb | 2 +- config/puma.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) 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