summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-04-12 14:39:54 +0000
committerRémy Coutable <remy@rymai.me>2016-04-12 14:39:54 +0000
commit0b8852d3c4cee2dba509fe56219036ab56a111e0 (patch)
tree87dcc4d59308c48e38bd56c7c8669549250d5868
parent13201a3a0513082197ab7f9bf04a6944e58e0646 (diff)
parent435892ed4398afb67043c62be8831df07d2078f2 (diff)
downloadgitlab-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
-rw-r--r--CHANGELOG1
-rw-r--r--config/initializers/metrics.rb12
2 files changed, 13 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 5744ed6adac..a294c750ccb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
v 8.7.0 (unreleased)
+ - All service classes (those residing in app/services) are now instrumented (Yorick Peterse)
- Enable gzip for assets, makes the page size significantly smaller. !3544 / !3632 (Connor Shea)
- Load award emoji images separately unless opening the full picker. Saves several hundred KBs of data for most pages. (Connor Shea)
- All images in discussions and wikis now link to their source files !3464 (Connor Shea).
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