15
15
*/
16
16
17
17
import { Meter } from './Meter' ;
18
- import { MetricOptions , Metric , Labels , LabelSet , MetricUtils } from './Metric' ;
18
+ import { MetricOptions , Metric , Labels , MetricUtils } from './Metric' ;
19
19
import { BoundMeasure , BoundCounter , BoundObserver } from './BoundInstrument' ;
20
20
import { CorrelationContext } from '../correlation_context/CorrelationContext' ;
21
21
import { SpanContext } from '../trace/span_context' ;
@@ -54,10 +54,6 @@ export class NoopMeter implements Meter {
54
54
createObserver ( name : string , options ?: MetricOptions ) : Metric < BoundObserver > {
55
55
return NOOP_OBSERVER_METRIC ;
56
56
}
57
-
58
- labels ( labels : Labels ) : LabelSet {
59
- return NOOP_LABEL_SET ;
60
- }
61
57
}
62
58
63
59
export class NoopMetric < T > implements Metric < T > {
@@ -67,22 +63,21 @@ export class NoopMetric<T> implements Metric<T> {
67
63
this . _instrument = instrument ;
68
64
}
69
65
/**
70
- * Returns a Bound Instrument associated with specified LabelSet .
66
+ * Returns a Bound Instrument associated with specified Labels .
71
67
* It is recommended to keep a reference to the Bound Instrument instead of
72
68
* always calling this method for every operations.
73
- * @param labels the canonicalized LabelSet used to associate with this
74
- * metric instrument .
69
+ * @param labels key-values pairs that are associated with a specific metric
70
+ * that you want to record .
75
71
*/
76
- bind ( labels : LabelSet ) : T {
72
+ bind ( labels : Labels ) : T {
77
73
return this . _instrument ;
78
74
}
79
75
80
76
/**
81
77
* Removes the Binding from the metric, if it is present.
82
- * @param labels the canonicalized LabelSet used to associate with this
83
- * metric instrument.
78
+ * @param labels key-values pairs that are associated with a specific metric.
84
79
*/
85
- unbind ( labels : LabelSet ) : void {
80
+ unbind ( labels : Labels ) : void {
86
81
return ;
87
82
}
88
83
@@ -96,25 +91,25 @@ export class NoopMetric<T> implements Metric<T> {
96
91
97
92
export class NoopCounterMetric extends NoopMetric < BoundCounter >
98
93
implements Pick < MetricUtils , 'add' > {
99
- add ( value : number , labelSet : LabelSet ) {
100
- this . bind ( labelSet ) . add ( value ) ;
94
+ add ( value : number , labels : Labels ) {
95
+ this . bind ( labels ) . add ( value ) ;
101
96
}
102
97
}
103
98
104
99
export class NoopMeasureMetric extends NoopMetric < BoundMeasure >
105
100
implements Pick < MetricUtils , 'record' > {
106
101
record (
107
102
value : number ,
108
- labelSet : LabelSet ,
103
+ labels : Labels ,
109
104
correlationContext ?: CorrelationContext ,
110
105
spanContext ?: SpanContext
111
106
) {
112
107
if ( typeof correlationContext === 'undefined' ) {
113
- this . bind ( labelSet ) . record ( value ) ;
108
+ this . bind ( labels ) . record ( value ) ;
114
109
} else if ( typeof spanContext === 'undefined' ) {
115
- this . bind ( labelSet ) . record ( value , correlationContext ) ;
110
+ this . bind ( labels ) . record ( value , correlationContext ) ;
116
111
} else {
117
- this . bind ( labelSet ) . record ( value , correlationContext , spanContext ) ;
112
+ this . bind ( labels ) . record ( value , correlationContext , spanContext ) ;
118
113
}
119
114
}
120
115
}
@@ -153,5 +148,3 @@ export const NOOP_MEASURE_METRIC = new NoopMeasureMetric(NOOP_BOUND_MEASURE);
153
148
154
149
export const NOOP_BOUND_OBSERVER = new NoopBoundObserver ( ) ;
155
150
export const NOOP_OBSERVER_METRIC = new NoopObserverMetric ( NOOP_BOUND_OBSERVER ) ;
156
-
157
- export const NOOP_LABEL_SET = { } as LabelSet ;
0 commit comments