Track call counts in Gitlab::Metrics.measure_block

This commit is contained in:
Yorick Peterse 2016-04-11 13:27:24 +02:00
parent 185d78bcb3
commit d9110a7eca
No known key found for this signature in database
GPG key ID: EDD30D2BEB691AC9
3 changed files with 8 additions and 3 deletions

View file

@ -14,10 +14,11 @@ Gitlab::Metrics.measure(:foo) do
end
```
Two values are measured for a block:
3 values are measured for a block:
1. The real time elapsed, stored in NAME_real_time
2. The CPU time elapsed, stored in NAME_cpu_time
1. The real time elapsed, stored in NAME_real_time.
2. The CPU time elapsed, stored in NAME_cpu_time.
3. The call count, stored in NAME_call_count.
Both the real and CPU timings are measured in milliseconds.

View file

@ -97,6 +97,7 @@ module Gitlab
Transaction.current.increment("#{name}_real_time", real_time)
Transaction.current.increment("#{name}_cpu_time", cpu_time)
Transaction.current.increment("#{name}_call_count", 1)
retval
end

View file

@ -85,6 +85,9 @@ describe Gitlab::Metrics do
expect(transaction).to receive(:increment).
with('foo_cpu_time', a_kind_of(Numeric))
expect(transaction).to receive(:increment).
with('foo_call_count', 1)
Gitlab::Metrics.measure(:foo) { 10 }
end