@@ -788,7 +788,7 @@ describe('metrics-middleware', () => {
788
788
Prometheus . register . clear ( ) ;
789
789
} ) ;
790
790
} ) ;
791
- describe ( 'when excludeDefaultMetricLabels is passed ' , ( ) => {
791
+ describe ( 'when calling the function with excludeDefaultMetricLabels option ' , ( ) => {
792
792
it ( 'or it\'s undefined' , ( ) => {
793
793
middleware ( ) ;
794
794
expect ( Prometheus . register . getSingleMetric ( 'http_request_size_bytes' ) . labelNames ) . to . have . members ( [ 'method' , 'route' , 'code' ] ) ;
@@ -822,5 +822,43 @@ describe('metrics-middleware', () => {
822
822
Prometheus . register . clear ( ) ;
823
823
} ) ;
824
824
} ) ;
825
+ describe ( 'when calling the function with useCountersForRequestSizeMetric option' , ( ) => {
826
+ before ( ( ) => {
827
+ middleware ( {
828
+ useCountersForRequestSizeMetric : true
829
+ } ) ;
830
+ } ) ;
831
+ it ( 'shouldn\'t have http_request_size_bytes metric' , ( ) => {
832
+ expect ( Prometheus . register . getSingleMetric ( 'http_request_size_bytes' ) ) . to . equal ( undefined ) ;
833
+ } ) ;
834
+ it ( 'should have http_request_size_bytes_sum with the right labels' , ( ) => {
835
+ expect ( Prometheus . register . getSingleMetric ( 'http_request_size_bytes_sum' ) . labelNames ) . to . have . members ( [ 'method' , 'route' , 'code' ] ) ;
836
+ } ) ;
837
+ it ( 'should have http_request_size_bytes_count with the right labels' , ( ) => {
838
+ expect ( Prometheus . register . getSingleMetric ( 'http_request_size_bytes_count' ) . labelNames ) . to . have . members ( [ 'method' , 'route' , 'code' ] ) ;
839
+ } ) ;
840
+ after ( ( ) => {
841
+ Prometheus . register . clear ( ) ;
842
+ } ) ;
843
+ } ) ;
844
+ describe ( 'when calling the function with useCountersForResponseSizeMetric option' , ( ) => {
845
+ before ( ( ) => {
846
+ middleware ( {
847
+ useCountersForResponseSizeMetric : true
848
+ } ) ;
849
+ } ) ;
850
+ it ( 'shouldn\'t have http_response_size_bytes metric' , ( ) => {
851
+ expect ( Prometheus . register . getSingleMetric ( 'http_response_size_bytes' ) ) . to . equal ( undefined ) ;
852
+ } ) ;
853
+ it ( 'should have http_response_size_bytes_sum with the right labels' , ( ) => {
854
+ expect ( Prometheus . register . getSingleMetric ( 'http_response_size_bytes_sum' ) . labelNames ) . to . have . members ( [ 'method' , 'route' , 'code' ] ) ;
855
+ } ) ;
856
+ it ( 'should have http_response_size_bytes_count with the right labels' , ( ) => {
857
+ expect ( Prometheus . register . getSingleMetric ( 'http_response_size_bytes_count' ) . labelNames ) . to . have . members ( [ 'method' , 'route' , 'code' ] ) ;
858
+ } ) ;
859
+ after ( ( ) => {
860
+ Prometheus . register . clear ( ) ;
861
+ } ) ;
862
+ } ) ;
825
863
} ) ;
826
864
} ) ;
0 commit comments