mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-01-18 16:27:28 +01:00
add types for metricType: summary
This commit is contained in:
10
types/index.d.ts
vendored
10
types/index.d.ts
vendored
@@ -19,7 +19,6 @@ declare namespace express_prom_bundle {
|
||||
|
||||
interface Opts {
|
||||
autoregister?: boolean;
|
||||
buckets?: number[];
|
||||
|
||||
customLabels?: { [key: string]: any };
|
||||
|
||||
@@ -31,6 +30,15 @@ declare namespace express_prom_bundle {
|
||||
bypass?: (req: Request) => boolean;
|
||||
|
||||
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 };
|
||||
|
||||
@@ -40,7 +40,7 @@ promBundle({
|
||||
...labels,
|
||||
year: new Date().getFullYear()
|
||||
}),
|
||||
metricType: 'summary',
|
||||
metricType: 'histogram',
|
||||
metricsPath: '/prometheus',
|
||||
promClient: {
|
||||
collectDefaultMetrics: {
|
||||
@@ -59,6 +59,21 @@ promBundle({
|
||||
formatStatusCode: (res: Response) => res.statusCode + 100
|
||||
});
|
||||
|
||||
promClient.register.clear();
|
||||
|
||||
promBundle({
|
||||
metricType: 'summary',
|
||||
maxAgeSeconds: 600,
|
||||
ageBuckets: 5
|
||||
});
|
||||
|
||||
promClient.register.clear();
|
||||
|
||||
promBundle({
|
||||
metricType: 'summary',
|
||||
percentiles: [0.01, 0.1, 0.9, 0.99]
|
||||
});
|
||||
|
||||
// TypeScript workaround to write a readonly field
|
||||
type Writable<T> = { -readonly [K in keyof T]: T[K] };
|
||||
const wPromBundle: Writable<promBundle> = promBundle;
|
||||
|
||||
Reference in New Issue
Block a user