@@ -19,25 +19,25 @@ import * as sinon from 'sinon';
19
19
import { InstrumentationScope } from '@opentelemetry/core' ;
20
20
import { Resource } from '@opentelemetry/resources' ;
21
21
import {
22
- InstrumentType ,
23
- MeterProvider ,
24
- MetricReader ,
25
22
DataPoint ,
26
23
DataPointType ,
27
24
Histogram ,
25
+ InstrumentType ,
26
+ MeterProvider ,
28
27
MetricDescriptor ,
28
+ MetricReader ,
29
29
} from '../src' ;
30
30
import {
31
31
TestDeltaMetricReader ,
32
32
TestMetricReader ,
33
33
} from './export/TestMetricReader' ;
34
34
import {
35
- assertMetricData ,
36
35
assertDataPoint ,
37
- commonValues ,
36
+ assertMetricData ,
38
37
commonAttributes ,
39
- defaultResource ,
38
+ commonValues ,
40
39
defaultInstrumentationScope ,
40
+ defaultResource ,
41
41
} from './util' ;
42
42
import { ObservableResult , ValueType } from '@opentelemetry/api' ;
43
43
@@ -764,6 +764,41 @@ describe('Instruments', () => {
764
764
} ) ;
765
765
} ) ;
766
766
} ) ;
767
+
768
+ describe ( 'Gauge' , ( ) => {
769
+ it ( 'should record common values and attributes without exceptions' , async ( ) => {
770
+ const { meter } = setup ( ) ;
771
+ const gauge = meter . createGauge ( 'test' ) ;
772
+
773
+ for ( const values of commonValues ) {
774
+ for ( const attributes of commonAttributes ) {
775
+ gauge . record ( values , attributes ) ;
776
+ }
777
+ }
778
+ } ) ;
779
+
780
+ it ( 'should record values' , async ( ) => {
781
+ const { meter, cumulativeReader } = setup ( ) ;
782
+ const gauge = meter . createGauge ( 'test' ) ;
783
+
784
+ gauge . record ( 1 , { foo : 'bar' } ) ;
785
+ gauge . record ( - 1 ) ;
786
+
787
+ await validateExport ( cumulativeReader , {
788
+ dataPointType : DataPointType . GAUGE ,
789
+ dataPoints : [
790
+ {
791
+ attributes : { foo : 'bar' } ,
792
+ value : 1 ,
793
+ } ,
794
+ {
795
+ attributes : { } ,
796
+ value : - 1 ,
797
+ } ,
798
+ ] ,
799
+ } ) ;
800
+ } ) ;
801
+ } ) ;
767
802
} ) ;
768
803
769
804
function setup ( ) {
0 commit comments