summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-04-12 12:24:16 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2016-04-12 12:24:16 +0200
commit8299129382e59a0b407be8c476b8ae2d0704d688 (patch)
tree7e74ae75704800be7a1966401e8f571894f5b9bf /config
parent8cb41f19891e4f39c64abd6b2a273625103c5f43 (diff)
downloadgitlab-ce-8299129382e59a0b407be8c476b8ae2d0704d688.tar.gz
Instrument all service classesinstrument-service-classes
Fixes gitlab-org/gitlab-ce#15162
Diffstat (limited to 'config')
-rw-r--r--config/initializers/metrics.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/config/initializers/metrics.rb b/config/initializers/metrics.rb
index 1b445bbbd10..9bd43dad0a0 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'
@@ -98,6 +99,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