diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-17 17:45:37 +0200 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-06-17 13:09:55 -0400 |
commit | be3b8784431d8f788d174fce2f1b17ddc1cf3429 (patch) | |
tree | 11894d8f9d4b620adce054a3bfa73c5f26e02b31 /doc/development/instrumentation.md | |
parent | 1ca1ebc09bda279dcbacfcfaf39e0410f94ca985 (diff) | |
download | gitlab-ce-be3b8784431d8f788d174fce2f1b17ddc1cf3429.tar.gz |
Track method call times/counts as a single metric
Previously we'd create a separate Metric instance for every method call
that would exceed the method call threshold. This is problematic because
it doesn't provide us with information to accurately get the _total_
execution time of a particular method. For example, if the method
"Foo#bar" was called 4 times with a runtime of ~10 milliseconds we'd end
up with 4 different Metric instances. If we were to then get the
average/95th percentile/etc of the timings this would be roughly 10
milliseconds. However, the _actual_ total time spent in this method
would be around 40 milliseconds.
To solve this problem we now create a single Metric instance per method.
This Metric instance contains the _total_ real/CPU time and the call
count for every instrumented method.
Diffstat (limited to 'doc/development/instrumentation.md')
-rw-r--r-- | doc/development/instrumentation.md | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/doc/development/instrumentation.md b/doc/development/instrumentation.md index 6cd9b274d11..c2272ab0a2b 100644 --- a/doc/development/instrumentation.md +++ b/doc/development/instrumentation.md @@ -94,23 +94,8 @@ Visibility: public Number of lines: 21 def #{name}(#{args_signature}) - trans = Gitlab::Metrics::Instrumentation.transaction - - if trans - start = Time.now - cpu_start = Gitlab::Metrics::System.cpu_time - retval = super - duration = (Time.now - start) * 1000.0 - - if duration >= Gitlab::Metrics.method_call_threshold - cpu_duration = Gitlab::Metrics::System.cpu_time - cpu_start - - trans.add_metric(Gitlab::Metrics::Instrumentation::SERIES, - { duration: duration, cpu_duration: cpu_duration }, - method: #{label.inspect}) - end - - retval + if trans = Gitlab::Metrics::Instrumentation.transaction + trans.measure_method(#{label.inspect}) { super } else super end |