Passed
Push — master ( 795b66...a17000 )
by Zhenyu
01:23
created

Timer.start   A

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 2
1
import prometheus from 'prom-client';
2
3
import objectOnlyKeys from 'utils/object-only-keys';
4
// import objectContains from 'utils/object-contains';
5
6
const { Summary } = prometheus;
7
8
export default class Timer extends Summary {
9
  start(untrimmedLabels = {}) {
10
    const { labelNames } = this;
11
    const labels = objectOnlyKeys(untrimmedLabels, labelNames);
12
    const timerStopper = this.startTimer(labels);
13
    return dirtyEndLabels => {
14
      const endLabels = objectOnlyKeys(dirtyEndLabels, labelNames);
15
      timerStopper(endLabels);
16
    };
17
  }
18
}
19