Track call counts in Gitlab::Metrics.measure_block
This commit is contained in:
parent
185d78bcb3
commit
d9110a7eca
3 changed files with 8 additions and 3 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue