15
15
*/
16
16
17
17
import { Meter } from './Meter' ;
18
- import { MetricOptions , Metric , Labels , MetricUtils } from './Metric' ;
19
- import { BoundMeasure , BoundCounter , BoundObserver } from './BoundInstrument' ;
18
+ import {
19
+ MetricOptions ,
20
+ UnboundMetric ,
21
+ Labels ,
22
+ Counter ,
23
+ Measure ,
24
+ Observer ,
25
+ } from './Metric' ;
26
+ import { BoundMeasure , BoundCounter } from './BoundInstrument' ;
20
27
import { CorrelationContext } from '../correlation_context/CorrelationContext' ;
21
28
import { SpanContext } from '../trace/span_context' ;
22
29
import { ObserverResult } from './ObserverResult' ;
@@ -33,7 +40,7 @@ export class NoopMeter implements Meter {
33
40
* @param name the name of the metric.
34
41
* @param [options] the metric options.
35
42
*/
36
- createMeasure ( name : string , options ?: MetricOptions ) : Metric < BoundMeasure > {
43
+ createMeasure ( name : string , options ?: MetricOptions ) : Measure {
37
44
return NOOP_MEASURE_METRIC ;
38
45
}
39
46
@@ -42,7 +49,7 @@ export class NoopMeter implements Meter {
42
49
* @param name the name of the metric.
43
50
* @param [options] the metric options.
44
51
*/
45
- createCounter ( name : string , options ?: MetricOptions ) : Metric < BoundCounter > {
52
+ createCounter ( name : string , options ?: MetricOptions ) : Counter {
46
53
return NOOP_COUNTER_METRIC ;
47
54
}
48
55
@@ -51,12 +58,12 @@ export class NoopMeter implements Meter {
51
58
* @param name the name of the metric.
52
59
* @param [options] the metric options.
53
60
*/
54
- createObserver ( name : string , options ?: MetricOptions ) : Metric < BoundObserver > {
61
+ createObserver ( name : string , options ?: MetricOptions ) : Observer {
55
62
return NOOP_OBSERVER_METRIC ;
56
63
}
57
64
}
58
65
59
- export class NoopMetric < T > implements Metric < T > {
66
+ export class NoopMetric < T > implements UnboundMetric < T > {
60
67
private readonly _instrument : T ;
61
68
62
69
constructor ( instrument : T ) {
@@ -90,14 +97,14 @@ export class NoopMetric<T> implements Metric<T> {
90
97
}
91
98
92
99
export class NoopCounterMetric extends NoopMetric < BoundCounter >
93
- implements Pick < MetricUtils , 'add' > {
100
+ implements Counter {
94
101
add ( value : number , labels : Labels ) {
95
102
this . bind ( labels ) . add ( value ) ;
96
103
}
97
104
}
98
105
99
106
export class NoopMeasureMetric extends NoopMetric < BoundMeasure >
100
- implements Pick < MetricUtils , 'record' > {
107
+ implements Measure {
101
108
record (
102
109
value : number ,
103
110
labels : Labels ,
@@ -114,8 +121,7 @@ export class NoopMeasureMetric extends NoopMetric<BoundMeasure>
114
121
}
115
122
}
116
123
117
- export class NoopObserverMetric extends NoopMetric < BoundObserver >
118
- implements Pick < MetricUtils , 'setCallback' > {
124
+ export class NoopObserverMetric extends NoopMetric < void > implements Observer {
119
125
setCallback ( callback : ( observerResult : ObserverResult ) => void ) : void { }
120
126
}
121
127
@@ -135,16 +141,11 @@ export class NoopBoundMeasure implements BoundMeasure {
135
141
}
136
142
}
137
143
138
- export class NoopBoundObserver implements BoundObserver {
139
- setCallback ( callback : ( observerResult : ObserverResult ) => void ) : void { }
140
- }
141
-
142
144
export const NOOP_METER = new NoopMeter ( ) ;
143
145
export const NOOP_BOUND_COUNTER = new NoopBoundCounter ( ) ;
144
146
export const NOOP_COUNTER_METRIC = new NoopCounterMetric ( NOOP_BOUND_COUNTER ) ;
145
147
146
148
export const NOOP_BOUND_MEASURE = new NoopBoundMeasure ( ) ;
147
149
export const NOOP_MEASURE_METRIC = new NoopMeasureMetric ( NOOP_BOUND_MEASURE ) ;
148
150
149
- export const NOOP_BOUND_OBSERVER = new NoopBoundObserver ( ) ;
150
- export const NOOP_OBSERVER_METRIC = new NoopObserverMetric ( NOOP_BOUND_OBSERVER ) ;
151
+ export const NOOP_OBSERVER_METRIC = new NoopObserverMetric ( ) ;
0 commit comments