diff --git a/app/controllers/api/v1/moves_actions.rb b/app/controllers/api/v1/moves_actions.rb index 259300e65..c062da572 100644 --- a/app/controllers/api/v1/moves_actions.rb +++ b/app/controllers/api/v1/moves_actions.rb @@ -24,7 +24,7 @@ def create_and_render Notifier.prepare_notifications(topic: move, action_name: 'create') - Metrics.instance.record_move_count + PrometheusMetrics.instance.record_move_count render_move(move, :created) end diff --git a/app/controllers/api/v2/moves_actions.rb b/app/controllers/api/v2/moves_actions.rb index 6f50fa1f8..b4c07dfd6 100644 --- a/app/controllers/api/v2/moves_actions.rb +++ b/app/controllers/api/v2/moves_actions.rb @@ -29,7 +29,7 @@ def create_and_render create_automatic_event!(eventable: move, event_class: GenericEvent::MoveProposed) if move.proposed? create_automatic_event!(eventable: move, event_class: GenericEvent::MoveRequested) if move.requested? - Metrics.instance.record_move_count + PrometheusMetrics.instance.record_move_count render_move(move, :created) end diff --git a/app/lib/metrics.rb b/app/lib/prometheus_metrics.rb similarity index 96% rename from app/lib/metrics.rb rename to app/lib/prometheus_metrics.rb index 2c354cce2..507c51139 100644 --- a/app/lib/metrics.rb +++ b/app/lib/prometheus_metrics.rb @@ -2,7 +2,7 @@ require 'prometheus/client/data_stores/direct_file_store' -class Metrics +class PrometheusMetrics include Singleton def configure diff --git a/config.ru b/config.ru index c48fb7be3..807cfb81f 100644 --- a/config.ru +++ b/config.ru @@ -6,7 +6,7 @@ require 'prometheus/middleware/exporter' use Prometheus::Middleware::Collector use Prometheus::Middleware::Exporter -Metrics.instance.record_move_count +PrometheusMetrics.instance.record_move_count run Rails.application Rails.application.load_server diff --git a/config/initializers/metrics.rb b/config/initializers/metrics.rb deleted file mode 100644 index 4e8a04bb2..000000000 --- a/config/initializers/metrics.rb +++ /dev/null @@ -1,3 +0,0 @@ -# frozen_string_literal: true - -Metrics.instance.configure diff --git a/config/initializers/prometheus_metrics.rb b/config/initializers/prometheus_metrics.rb new file mode 100644 index 000000000..67c032e2f --- /dev/null +++ b/config/initializers/prometheus_metrics.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +PrometheusMetrics.instance.configure diff --git a/spec/lib/metrics_spec.rb b/spec/lib/prometheus_metrics_spec.rb similarity index 97% rename from spec/lib/metrics_spec.rb rename to spec/lib/prometheus_metrics_spec.rb index 8d9809803..9a930bd9f 100644 --- a/spec/lib/metrics_spec.rb +++ b/spec/lib/prometheus_metrics_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Metrics do +RSpec.describe PrometheusMetrics do subject(:instance) { described_class.send(:new) } let(:registry) { instance_double(Prometheus::Client::Registry) } diff --git a/spec/requests/api/moves_controller_create_spec.rb b/spec/requests/api/moves_controller_create_spec.rb index 980d0a272..aff8914c5 100644 --- a/spec/requests/api/moves_controller_create_spec.rb +++ b/spec/requests/api/moves_controller_create_spec.rb @@ -44,7 +44,7 @@ let(:content_type) { ApiController::CONTENT_TYPE } before do - allow_any_instance_of(Metrics).to receive(:record_move_count) # rubocop:disable RSpec/AnyInstance + allow_any_instance_of(PrometheusMetrics).to receive(:record_move_count) # rubocop:disable RSpec/AnyInstance end context 'when successful' do @@ -74,7 +74,7 @@ end it 'records the move count metric' do - expect_any_instance_of(Metrics).to receive(:record_move_count) # rubocop:disable RSpec/AnyInstance + expect_any_instance_of(PrometheusMetrics).to receive(:record_move_count) # rubocop:disable RSpec/AnyInstance post_moves end diff --git a/spec/requests/api/moves_controller_create_v2_spec.rb b/spec/requests/api/moves_controller_create_v2_spec.rb index 23cf7ccb7..5ca19bf15 100644 --- a/spec/requests/api/moves_controller_create_v2_spec.rb +++ b/spec/requests/api/moves_controller_create_v2_spec.rb @@ -60,7 +60,7 @@ before do allow(person).to receive(:update_nomis_data) allow_any_instance_of(Move).to receive(:person).and_return(person) # rubocop:disable RSpec/AnyInstance - allow_any_instance_of(Metrics).to receive(:record_move_count) # rubocop:disable RSpec/AnyInstance + allow_any_instance_of(PrometheusMetrics).to receive(:record_move_count) # rubocop:disable RSpec/AnyInstance end it_behaves_like 'an endpoint that responds with success 201' do @@ -88,7 +88,7 @@ end it 'records the move count metric' do - expect_any_instance_of(Metrics).to receive(:record_move_count) # rubocop:disable RSpec/AnyInstance + expect_any_instance_of(PrometheusMetrics).to receive(:record_move_count) # rubocop:disable RSpec/AnyInstance do_post end