File tree 3 files changed +44
-7
lines changed
3 files changed +44
-7
lines changed Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
- import { MetricOptions , Counter , ValueRecorder , Observer } from './Metric' ;
17
+ import {
18
+ MetricOptions ,
19
+ Counter ,
20
+ ValueRecorder ,
21
+ Observer ,
22
+ UpDownCounter ,
23
+ } from './Metric' ;
18
24
19
25
/**
20
26
* An interface to allow the recording metrics.
@@ -40,6 +46,25 @@ export interface Meter {
40
46
*/
41
47
createCounter ( name : string , options ?: MetricOptions ) : Counter ;
42
48
49
+ /**
50
+ * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous
51
+ * instrument and very similar to Counter except that Add(increment)
52
+ * supports negative increments. It is generally useful for capturing changes
53
+ * in an amount of resources used, or any quantity that rises and falls
54
+ * during a request.
55
+ * Example uses for UpDownCounter:
56
+ * <ol>
57
+ * <li> count the number of active requests. </li>
58
+ * <li> count memory in use by instrumenting new and delete. </li>
59
+ * <li> count queue size by instrumenting enqueue and dequeue. </li>
60
+ * <li> count semaphore up and down operations. </li>
61
+ * </ol>
62
+ *
63
+ * @param name the name of the metric.
64
+ * @param [options] the metric options.
65
+ */
66
+ createUpDownCounter ( name : string , options ?: MetricOptions ) : UpDownCounter ;
67
+
43
68
/**
44
69
* Creates a new `Observer` metric.
45
70
* @param name the name of the metric.
Original file line number Diff line number Diff line change @@ -48,12 +48,7 @@ export interface MetricOptions {
48
48
disabled ?: boolean ;
49
49
50
50
/**
51
- * Asserts that this metric may only increase (e.g. time spent).
52
- */
53
- monotonic ?: boolean ;
54
-
55
- /**
56
- * (ValueRecorder only, default true) Asserts that this metric will only accept
51
+ * (Measure only, default true) Asserts that this metric will only accept
57
52
* non-negative values (e.g. disk usage).
58
53
*/
59
54
absolute ?: boolean ;
@@ -125,6 +120,13 @@ export interface Counter extends UnboundMetric<BoundCounter> {
125
120
add ( value : number , labels ?: Labels ) : void ;
126
121
}
127
122
123
+ export interface UpDownCounter extends UnboundMetric < BoundCounter > {
124
+ /**
125
+ * Adds the given value to the current value. Values can be negative.
126
+ */
127
+ add ( value : number , labels ?: Labels ) : void ;
128
+ }
129
+
128
130
export interface ValueRecorder extends UnboundMetric < BoundValueRecorder > {
129
131
/**
130
132
* Records the given value to this value recorder.
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
22
22
Counter ,
23
23
ValueRecorder ,
24
24
Observer ,
25
+ UpDownCounter ,
25
26
} from './Metric' ;
26
27
import { BoundValueRecorder , BoundCounter } from './BoundInstrument' ;
27
28
import { CorrelationContext } from '../correlation_context/CorrelationContext' ;
@@ -53,6 +54,15 @@ export class NoopMeter implements Meter {
53
54
return NOOP_COUNTER_METRIC ;
54
55
}
55
56
57
+ /**
58
+ * Returns a constant noop UpDownCounter.
59
+ * @param name the name of the metric.
60
+ * @param [options] the metric options.
61
+ */
62
+ createUpDownCounter ( name : string , options ?: MetricOptions ) : UpDownCounter {
63
+ return NOOP_COUNTER_METRIC ;
64
+ }
65
+
56
66
/**
57
67
* Returns constant noop observer.
58
68
* @param name the name of the metric.
You can’t perform that action at this time.
0 commit comments