diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-12 14:39:54 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-04-12 14:39:54 +0000 |
commit | 0b8852d3c4cee2dba509fe56219036ab56a111e0 (patch) | |
tree | 87dcc4d59308c48e38bd56c7c8669549250d5868 /config | |
parent | 13201a3a0513082197ab7f9bf04a6944e58e0646 (diff) | |
parent | 435892ed4398afb67043c62be8831df07d2078f2 (diff) | |
download | gitlab-ce-0b8852d3c4cee2dba509fe56219036ab56a111e0.tar.gz |
Merge branch 'instrument-service-classes' into 'master'
Instrument all service classes
This will help us see where (mostly) Sidekiq code is spending time.
See merge request !3675
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/metrics.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/config/initializers/metrics.rb b/config/initializers/metrics.rb index e85ac22f10f..22fe51a4534 100644 --- a/config/initializers/metrics.rb +++ b/config/initializers/metrics.rb @@ -1,4 +1,5 @@ if Gitlab::Metrics.enabled? + require 'pathname' require 'influxdb' require 'connection_pool' require 'method_source' @@ -95,6 +96,17 @@ if Gitlab::Metrics.enabled? config.instrument_methods(Gitlab::ReferenceExtractor) config.instrument_instance_methods(Gitlab::ReferenceExtractor) + + # Instrument all service classes + services = Rails.root.join('app', 'services') + + Dir[services.join('**', '*.rb')].each do |file_path| + path = Pathname.new(file_path).relative_path_from(services) + const = path.to_s.sub('.rb', '').camelize.constantize + + config.instrument_methods(const) + config.instrument_instance_methods(const) + end end GC::Profiler.enable |