summaryrefslogtreecommitdiff
path: root/lib/gitlab/metrics/subscribers
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2015-12-10 15:16:56 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2015-12-17 17:25:48 +0100
commit1b077d2d81bd25fe37492ea56c8bd884f944ce52 (patch)
tree0f04a2f411f6d20bcbd8ed2975ff2d1a1409ec9f /lib/gitlab/metrics/subscribers
parentb66a16c8384b64eabeb04f3f32017581e4711eb8 (diff)
downloadgitlab-ce-1b077d2d81bd25fe37492ea56c8bd884f944ce52.tar.gz
Use custom code for instrumenting method calls
The use of ActiveSupport would slow down instrumented method calls by about 180x due to: 1. ActiveSupport itself not being the fastest thing on the planet 2. caller_locations() having quite some overhead The use of caller_locations() has been removed because it's not _that_ useful since we already know the full namespace of receivers and the names of the called methods. The use of ActiveSupport has been replaced with some custom code that's generated using eval() (which can be quite a bit faster than using define_method). This new setup results in instrumented methods only being about 35-40x slower (compared to non instrumented methods).
Diffstat (limited to 'lib/gitlab/metrics/subscribers')
-rw-r--r--lib/gitlab/metrics/subscribers/method_call.rb42
1 files changed, 0 insertions, 42 deletions
diff --git a/lib/gitlab/metrics/subscribers/method_call.rb b/lib/gitlab/metrics/subscribers/method_call.rb
deleted file mode 100644
index 0094ed0dc6a..00000000000
--- a/lib/gitlab/metrics/subscribers/method_call.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-module Gitlab
- module Metrics
- module Subscribers
- # Class for tracking method call timings.
- class MethodCall < ActiveSupport::Subscriber
- attach_to :method_call
-
- SERIES = 'method_calls'
-
- def instance_method(event)
- return unless current_transaction
-
- label = "#{event.payload[:module]}##{event.payload[:name]}"
-
- add_metric(label, event.duration)
- end
-
- def class_method(event)
- return unless current_transaction
-
- label = "#{event.payload[:module]}.#{event.payload[:name]}"
-
- add_metric(label, event.duration)
- end
-
- private
-
- def add_metric(label, duration)
- file, line = Metrics.last_relative_application_frame
-
- values = { duration: duration, file: file, line: line }
-
- current_transaction.add_metric(SERIES, values, method: label)
- end
-
- def current_transaction
- Transaction.current
- end
- end
- end
- end
-end