From 77b8c2c1768dc7e70a7b5f2bbfdf2b97d78dbfe9 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 20 Dec 2018 23:07:26 +0800 Subject: [PATCH] Always load the metrics the last Because this could potentially load a model and we shouldn't load models before all the patches we have in places. --- config/initializers/{8_metrics.rb => zz_metrics.rb} | 3 +++ doc/development/instrumentation.md | 2 +- spec/initializers/{8_metrics_spec.rb => zz_metrics_spec.rb} | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) rename config/initializers/{8_metrics.rb => zz_metrics.rb} (98%) rename spec/initializers/{8_metrics_spec.rb => zz_metrics_spec.rb} (92%) diff --git a/config/initializers/8_metrics.rb b/config/initializers/zz_metrics.rb similarity index 98% rename from config/initializers/8_metrics.rb rename to config/initializers/zz_metrics.rb index 468f80939d7..462e8c811a6 100644 --- a/config/initializers/8_metrics.rb +++ b/config/initializers/zz_metrics.rb @@ -1,3 +1,6 @@ +# This file was prefixed with zz_ because we want to load it the last! +# See: https://gitlab.com/gitlab-org/gitlab-ce/issues/55611 + # Autoload all classes that we want to instrument, and instrument the methods we # need. This takes the Gitlab::Metrics::Instrumentation module as an argument so # that we can stub it for testing, as it is only called when metrics are diff --git a/doc/development/instrumentation.md b/doc/development/instrumentation.md index bef166f2aec..a36dc6424a7 100644 --- a/doc/development/instrumentation.md +++ b/doc/development/instrumentation.md @@ -35,7 +35,7 @@ Using this method is in general preferred over directly calling the various instrumentation methods. Method instrumentation should be added in the initializer -`config/initializers/8_metrics.rb`. +`config/initializers/zz_metrics.rb`. ### Examples diff --git a/spec/initializers/8_metrics_spec.rb b/spec/initializers/zz_metrics_spec.rb similarity index 92% rename from spec/initializers/8_metrics_spec.rb rename to spec/initializers/zz_metrics_spec.rb index 80c77057065..3eaccfe8d8b 100644 --- a/spec/initializers/8_metrics_spec.rb +++ b/spec/initializers/zz_metrics_spec.rb @@ -16,7 +16,7 @@ describe 'instrument_classes' do end it 'can autoload and instrument all files' do - require_relative '../../config/initializers/8_metrics' + require_relative '../../config/initializers/zz_metrics' expect { instrument_classes(config) }.not_to raise_error end end