feat: respect pruneAgedBuckets, update README

This commit is contained in:
Timm Stelzer
2024-01-06 11:31:26 +01:00
committed by Konstantin Pogorelov
parent edfb9992ed
commit fd5ff1cfe0
4 changed files with 60 additions and 13 deletions

29
types/index.d.ts vendored
View File

@@ -17,7 +17,7 @@ declare namespace express_prom_bundle {
type NormalizeStatusCodeFn = (res: Response) => number | string;
type TransformLabelsFn = (labels: Labels, req: Request, res: Response) => void;
interface Opts {
interface BaseOptions {
autoregister?: boolean;
customLabels?: { [key: string]: any };
@@ -36,16 +36,6 @@ declare namespace express_prom_bundle {
excludeRoutes?: Array<string | RegExp>;
metricType?: 'summary' | 'histogram';
// https://github.com/siimon/prom-client#histogram
buckets?: number[];
// https://github.com/siimon/prom-client#summary
percentiles?: number[];
maxAgeSeconds?: number;
ageBuckets?: number;
metricsPath?: string;
httpDurationMetricName?: string;
promClient?: { collectDefaultMetrics?: DefaultMetricsCollectorConfiguration<RegistryContentType> };
@@ -65,6 +55,23 @@ declare namespace express_prom_bundle {
};
}
/** @see https://github.com/siimon/prom-client#summary */
type SummaryOptions = BaseOptions & {
metricType?: 'summary';
percentiles?: number[];
maxAgeSeconds?: number;
ageBuckets?: number;
pruneAgedBuckets?: boolean;
}
/** @see https://github.com/siimon/prom-client#histogram */
type HistogramOptions = BaseOptions & {
metricType?: 'histogram';
buckets?: number[];
}
type Opts = SummaryOptions | HistogramOptions;
interface Middleware extends RequestHandler {
metricsMiddleware: RequestHandler;
}