Commit 106e63e8 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '217978-disable-instrumentation-via-ff' into 'master'

Disable Instrumentation load under FF [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!69091
parents ef97d650 1ffca35f
---
name: method_instrumentation_disable_initialization
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69091
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339665
milestone: '14.3'
type: development
group: group::memory
default_enabled: false
...@@ -178,27 +178,33 @@ if Gitlab::Metrics.enabled? && !Rails.env.test? && !(Rails.env.development? && d ...@@ -178,27 +178,33 @@ if Gitlab::Metrics.enabled? && !Rails.env.test? && !(Rails.env.development? && d
ActiveRecord::Querying.public_instance_methods(false).map(&:to_s) ActiveRecord::Querying.public_instance_methods(false).map(&:to_s)
) )
Gitlab::Metrics::Instrumentation # We are removing the Instrumentation module entirely in steps.
.instrument_class_hierarchy(ActiveRecord::Base) do |klass, method| # More in https://gitlab.com/gitlab-org/gitlab/-/issues/217978.
# Instrumenting the ApplicationSetting class can lead to an infinite unless ::Feature.enabled?(:method_instrumentation_disable_initialization)
# loop. Since the data is cached any way we don't really need to Gitlab::Metrics::Instrumentation
# instrument it. .instrument_class_hierarchy(ActiveRecord::Base) do |klass, method|
if klass == ApplicationSetting # Instrumenting the ApplicationSetting class can lead to an infinite
false # loop. Since the data is cached any way we don't really need to
else # instrument it.
loc = method.source_location if klass == ApplicationSetting
false
loc && loc[0].start_with?(models_path) && method.source =~ regex else
loc = method.source_location
loc && loc[0].start_with?(models_path) && method.source =~ regex
end
end end
end
# Ability is in app/models, is not an ActiveRecord model, but should still # Ability is in app/models, is not an ActiveRecord model, but should still
# be instrumented. # be instrumented.
Gitlab::Metrics::Instrumentation.instrument_methods(Ability) Gitlab::Metrics::Instrumentation.instrument_methods(Ability)
end
end end
Gitlab::Metrics::Instrumentation.configure do |config| unless ::Feature.enabled?(:method_instrumentation_disable_initialization)
instrument_classes(config) Gitlab::Metrics::Instrumentation.configure do |config|
instrument_classes(config)
end
end end
GC::Profiler.enable GC::Profiler.enable
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment