diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-31 09:08:57 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-31 09:08:57 +0000 |
commit | b46d41d54b05eab84bb9653c111124b67f573dd8 (patch) | |
tree | d93565ff482acf086904dc96e5718143e69b9174 /config/initializers/zz_metrics.rb | |
parent | 8d15913bc406fea50faf8f80abf129e2e9a5f847 (diff) | |
download | gitlab-ce-b46d41d54b05eab84bb9653c111124b67f573dd8.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config/initializers/zz_metrics.rb')
-rw-r--r-- | config/initializers/zz_metrics.rb | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/config/initializers/zz_metrics.rb b/config/initializers/zz_metrics.rb index e352ff5090a..bb768070b1f 100644 --- a/config/initializers/zz_metrics.rb +++ b/config/initializers/zz_metrics.rb @@ -178,27 +178,33 @@ if Gitlab::Metrics.enabled? && !Rails.env.test? && !(Rails.env.development? && d ActiveRecord::Querying.public_instance_methods(false).map(&:to_s) ) - Gitlab::Metrics::Instrumentation - .instrument_class_hierarchy(ActiveRecord::Base) do |klass, method| - # Instrumenting the ApplicationSetting class can lead to an infinite - # loop. Since the data is cached any way we don't really need to - # instrument it. - if klass == ApplicationSetting - false - else - loc = method.source_location - - loc && loc[0].start_with?(models_path) && method.source =~ regex + # We are removing the Instrumentation module entirely in steps. + # More in https://gitlab.com/gitlab-org/gitlab/-/issues/217978. + unless ::Feature.enabled?(:method_instrumentation_disable_initialization) + Gitlab::Metrics::Instrumentation + .instrument_class_hierarchy(ActiveRecord::Base) do |klass, method| + # Instrumenting the ApplicationSetting class can lead to an infinite + # loop. Since the data is cached any way we don't really need to + # instrument it. + if klass == ApplicationSetting + false + else + loc = method.source_location + + loc && loc[0].start_with?(models_path) && method.source =~ regex + end end - end - # Ability is in app/models, is not an ActiveRecord model, but should still - # be instrumented. - Gitlab::Metrics::Instrumentation.instrument_methods(Ability) + # Ability is in app/models, is not an ActiveRecord model, but should still + # be instrumented. + Gitlab::Metrics::Instrumentation.instrument_methods(Ability) + end end - Gitlab::Metrics::Instrumentation.configure do |config| - instrument_classes(config) + unless ::Feature.enabled?(:method_instrumentation_disable_initialization) + Gitlab::Metrics::Instrumentation.configure do |config| + instrument_classes(config) + end end GC::Profiler.enable |