diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-15 18:38:25 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-17 19:25:48 +0300 |
commit | a41287d8989d7d49b405fd8f658d6c6e4edfd307 (patch) | |
tree | 283b85ee5892e999e029afdf035c7713e2dcdc0d /lib | |
parent | 13dbd663acbbe91ddac77b650a90377cd12c54b8 (diff) |
Only track method calls above a certain threshold
This ensures we don't end up wasting resources by tracking method calls
that only take a few microseconds. By default the threshold is 10
milliseconds but this can be changed using the gitlab.yml configuration
file.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/metrics.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/metrics/instrumentation.rb | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/gitlab/metrics.rb b/lib/gitlab/metrics.rb index 007429fa194..4b92c3244fa 100644 --- a/lib/gitlab/metrics.rb +++ b/lib/gitlab/metrics.rb @@ -16,6 +16,10 @@ module Gitlab !!Settings.metrics['enabled'] end + def self.method_call_threshold + Settings.metrics['method_call_threshold'] || 10 + end + def self.pool @pool end diff --git a/lib/gitlab/metrics/instrumentation.rb b/lib/gitlab/metrics/instrumentation.rb index 91e09694cd8..ca2dffbc46a 100644 --- a/lib/gitlab/metrics/instrumentation.rb +++ b/lib/gitlab/metrics/instrumentation.rb @@ -99,9 +99,11 @@ module Gitlab retval = __send__(#{alias_name.inspect}, *args, &block) duration = (Time.now - start) * 1000.0 - trans.add_metric(Gitlab::Metrics::Instrumentation::SERIES, - { duration: duration }, - method: #{label.inspect}) + if duration >= Gitlab::Metrics.method_call_threshold + trans.add_metric(Gitlab::Metrics::Instrumentation::SERIES, + { duration: duration }, + method: #{label.inspect}) + end retval else |