1- import type { Histogram , Summary } from 'prom-client' ;
1+ import type {
2+ Histogram , PrometheusContentType , Registry , RegistryContentType , Summary ,
3+ } from 'prom-client' ;
24import promClient from 'prom-client' ;
35import { MetricTypeName } from '../constants' ;
46import type { Options } from '../type' ;
57
6- export function buildRequestDurationMetric ( options : Options ) : Histogram | Summary {
8+ export function buildRequestDurationMetric <
9+ T extends RegistryContentType = PrometheusContentType ,
10+ > ( options : Options < T > ) : Histogram | Summary {
711 const labels : string [ ] = [
812 'method' ,
913 'path' ,
@@ -20,7 +24,7 @@ export function buildRequestDurationMetric(options: Options) : Histogram | Summa
2024 help : `duration (sec) summary of http responses labeled with: ${ labels . join ( ', ' ) } ` ,
2125 labelNames : labels ,
2226 percentiles : [ 0.5 , 0.75 , 0.95 , 0.98 , 0.99 , 0.999 ] ,
23- registers : [ options . registry ] ,
27+ registers : [ options . registry as Registry ] ,
2428 ...options . requestDurationSummary ,
2529 } ) ;
2630 }
@@ -30,7 +34,7 @@ export function buildRequestDurationMetric(options: Options) : Histogram | Summa
3034 help : `duration (sec) histogram of http responses labeled with: ${ labels . join ( ', ' ) } ` ,
3135 labelNames : labels ,
3236 buckets : [ 0.003 , 0.03 , 0.1 , 0.3 , 1.5 , 10 ] ,
33- registers : [ options . registry ] ,
37+ registers : [ options . registry as Registry ] ,
3438 ...options . requestDurationHistogram ,
3539 } ) ;
3640}
0 commit comments