UNPKG

1.24 kBPlain TextView Raw
1import * as express from 'express';
2import * as prometheus from 'prom-client';
3
4import { AggregatorStrategy } from './enums';
5
6export interface LabelSet {
7 [name: string]: string;
8}
9
10export interface CustomParams {
11 percentiles?: number[];
12 buckets?: number[];
13 labelNames?: string[];
14 aggregator?: AggregatorStrategy;
15}
16// weird class to allow polymorphism over constructors yielding type Metric
17export class MetricConstructor<T extends string = string> {
18 constructor(public construct: new (...args: any[]) => prometheus.Metric<T>) {}
19 public create(...args: any[]): prometheus.Metric<T> {
20 return new this.construct(...args);
21 }
22}
23
24export interface ConstructorMap {
25 [kind: string]: MetricConstructor;
26}
27
28export interface MetricsMap<T extends string = string> {
29 gauge: { [name: string]: prometheus.Gauge<T> };
30 counter: { [name: string]: prometheus.Counter<T> };
31 histogram: { [name: string]: prometheus.Histogram<T> };
32 summary: { [name: string]: prometheus.Summary<T> };
33}
34
35export type Kind = keyof MetricsMap;
36
37export interface MetricsMeta {
38 kind: Kind;
39 help: string;
40 customParams: CustomParams;
41}
42
43export interface MetricsMetaMap {
44 [name: string]: MetricsMeta;
45}
46
47export type AuthTestFunc = (req: express.Request) => boolean;