@@ -37,7 +37,7 @@ describe('PrometheusExporter', () => {
37
37
( ) => {
38
38
const url = `http://localhost:${ port } ${ endpoint } ` ;
39
39
http . get ( url , function ( res : any ) {
40
- assert . equal ( res . statusCode , 200 ) ;
40
+ assert . strictEqual ( res . statusCode , 200 ) ;
41
41
exporter . shutdown ( ( ) => {
42
42
return done ( ) ;
43
43
} ) ;
@@ -72,7 +72,7 @@ describe('PrometheusExporter', () => {
72
72
exporter . startServer ( ( ) => {
73
73
const url = `http://localhost:${ port } ${ endpoint } ` ;
74
74
http . get ( url , function ( res : any ) {
75
- assert . equal ( res . statusCode , 200 ) ;
75
+ assert . strictEqual ( res . statusCode , 200 ) ;
76
76
exporter . shutdown ( ( ) => {
77
77
return done ( ) ;
78
78
} ) ;
@@ -92,7 +92,7 @@ describe('PrometheusExporter', () => {
92
92
exporter . startServer ( ( ) => {
93
93
const url = `http://localhost:${ port } ${ endpoint } ` ;
94
94
http . get ( url , function ( res : any ) {
95
- assert . equal ( res . statusCode , 200 ) ;
95
+ assert . strictEqual ( res . statusCode , 200 ) ;
96
96
exporter . shutdown ( ( ) => {
97
97
return done ( ) ;
98
98
} ) ;
@@ -112,7 +112,7 @@ describe('PrometheusExporter', () => {
112
112
exporter . startServer ( ( ) => {
113
113
const url = `http://localhost:${ port } /metric` ;
114
114
http . get ( url , function ( res : any ) {
115
- assert . equal ( res . statusCode , 200 ) ;
115
+ assert . strictEqual ( res . statusCode , 200 ) ;
116
116
exporter . shutdown ( ( ) => {
117
117
const exporter2 = new PrometheusExporter ( {
118
118
port,
@@ -122,7 +122,7 @@ describe('PrometheusExporter', () => {
122
122
exporter2 . startServer ( ( ) => {
123
123
const url = `http://localhost:${ port } /metric` ;
124
124
http . get ( url , function ( res : any ) {
125
- assert . equal ( res . statusCode , 200 ) ;
125
+ assert . strictEqual ( res . statusCode , 200 ) ;
126
126
exporter2 . stopServer ( ( ) => {
127
127
return done ( ) ;
128
128
} ) ;
@@ -144,7 +144,7 @@ describe('PrometheusExporter', () => {
144
144
const url = `http://localhost:${ port } /invalid` ;
145
145
146
146
http . get ( url , function ( res : any ) {
147
- assert . equal ( res . statusCode , 404 ) ;
147
+ assert . strictEqual ( res . statusCode , 404 ) ;
148
148
exporter . shutdown ( ( ) => {
149
149
return done ( ) ;
150
150
} ) ;
@@ -199,7 +199,7 @@ describe('PrometheusExporter', () => {
199
199
'# HELP counter a test description'
200
200
) ;
201
201
202
- assert . deepEqual ( lines , [
202
+ assert . deepStrictEqual ( lines , [
203
203
'# HELP counter a test description' ,
204
204
'# TYPE counter counter' ,
205
205
'counter{key1="labelValue1"} 20' ,
@@ -229,7 +229,7 @@ describe('PrometheusExporter', () => {
229
229
const body = chunk . toString ( ) ;
230
230
const lines = body . split ( '\n' ) ;
231
231
232
- assert . deepEqual ( lines , [
232
+ assert . deepStrictEqual ( lines , [
233
233
'# HELP gauge a test description' ,
234
234
'# TYPE gauge gauge' ,
235
235
'gauge{key1="labelValue1"} 10' ,
@@ -263,7 +263,7 @@ describe('PrometheusExporter', () => {
263
263
const body = chunk . toString ( ) ;
264
264
const lines = body . split ( '\n' ) ;
265
265
266
- assert . deepEqual ( lines , [
266
+ assert . deepStrictEqual ( lines , [
267
267
'# HELP gauge a test description' ,
268
268
'# TYPE gauge gauge' ,
269
269
'gauge{gaugeKey1="labelValue1"} 10' ,
@@ -289,7 +289,7 @@ describe('PrometheusExporter', () => {
289
289
const body = chunk . toString ( ) ;
290
290
const lines = body . split ( '\n' ) ;
291
291
292
- assert . deepEqual ( lines , [ '# no registered metrics' ] ) ;
292
+ assert . deepStrictEqual ( lines , [ '# no registered metrics' ] ) ;
293
293
294
294
done ( ) ;
295
295
} ) ;
@@ -310,7 +310,7 @@ describe('PrometheusExporter', () => {
310
310
const body = chunk . toString ( ) ;
311
311
const lines = body . split ( '\n' ) ;
312
312
313
- assert . deepEqual ( lines , [
313
+ assert . deepStrictEqual ( lines , [
314
314
'# HELP gauge description missing' ,
315
315
'# TYPE gauge gauge' ,
316
316
'gauge 10' ,
@@ -335,7 +335,7 @@ describe('PrometheusExporter', () => {
335
335
const body = chunk . toString ( ) ;
336
336
const lines = body . split ( '\n' ) ;
337
337
338
- assert . deepEqual ( lines , [
338
+ assert . deepStrictEqual ( lines , [
339
339
'# HELP gauge_bad_name description missing' ,
340
340
'# TYPE gauge_bad_name gauge' ,
341
341
'gauge_bad_name 10' ,
@@ -348,6 +348,33 @@ describe('PrometheusExporter', () => {
348
348
. on ( 'error' , errorHandler ( done ) ) ;
349
349
} ) ;
350
350
} ) ;
351
+
352
+ it ( 'should export a non-monotonic counter as a gauge' , done => {
353
+ const counter = meter . createCounter ( 'counter' , {
354
+ description : 'a test description' ,
355
+ monotonic : false ,
356
+ labelKeys : [ 'key1' ] ,
357
+ } ) as CounterMetric ;
358
+
359
+ const handle = counter . getHandle ( meter . labels ( { key1 : 'labelValue1' } ) ) ;
360
+ handle . add ( 20 ) ;
361
+ exporter . export ( meter . getMetrics ( ) , ( ) => {
362
+ http
363
+ . get ( 'http://localhost:9464/metrics' , res => {
364
+ res . on ( 'data' , chunk => {
365
+ assert . deepStrictEqual ( chunk . toString ( ) . split ( '\n' ) , [
366
+ '# HELP counter a test description' ,
367
+ '# TYPE counter gauge' ,
368
+ 'counter{key1="labelValue1"} 20' ,
369
+ '' ,
370
+ ] ) ;
371
+
372
+ done ( ) ;
373
+ } ) ;
374
+ } )
375
+ . on ( 'error' , errorHandler ( done ) ) ;
376
+ } ) ;
377
+ } ) ;
351
378
} ) ;
352
379
353
380
describe ( 'configuration' , ( ) => {
@@ -383,7 +410,7 @@ describe('PrometheusExporter', () => {
383
410
const body = chunk . toString ( ) ;
384
411
const lines = body . split ( '\n' ) ;
385
412
386
- assert . deepEqual ( lines , [
413
+ assert . deepStrictEqual ( lines , [
387
414
'# HELP test_prefix_gauge description missing' ,
388
415
'# TYPE test_prefix_gauge gauge' ,
389
416
'test_prefix_gauge 10' ,
@@ -411,7 +438,7 @@ describe('PrometheusExporter', () => {
411
438
const body = chunk . toString ( ) ;
412
439
const lines = body . split ( '\n' ) ;
413
440
414
- assert . deepEqual ( lines , [
441
+ assert . deepStrictEqual ( lines , [
415
442
'# HELP gauge description missing' ,
416
443
'# TYPE gauge gauge' ,
417
444
'gauge 10' ,
@@ -439,7 +466,7 @@ describe('PrometheusExporter', () => {
439
466
const body = chunk . toString ( ) ;
440
467
const lines = body . split ( '\n' ) ;
441
468
442
- assert . deepEqual ( lines , [
469
+ assert . deepStrictEqual ( lines , [
443
470
'# HELP gauge description missing' ,
444
471
'# TYPE gauge gauge' ,
445
472
'gauge 10' ,
0 commit comments