1 | import * as express from 'express';
|
2 | import * as prometheus from 'prom-client';
|
3 |
|
4 | import { AggregatorStrategy } from './enums';
|
5 |
|
6 | export interface LabelSet {
|
7 | [name: string]: string;
|
8 | }
|
9 |
|
10 | export interface CustomParams {
|
11 | percentiles?: number[];
|
12 | buckets?: number[];
|
13 | labelNames?: string[];
|
14 | aggregator?: AggregatorStrategy;
|
15 | }
|
16 |
|
17 | export 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 |
|
24 | export interface ConstructorMap {
|
25 | [kind: string]: MetricConstructor;
|
26 | }
|
27 |
|
28 | export 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 |
|
35 | export type Kind = keyof MetricsMap;
|
36 |
|
37 | export interface MetricsMeta {
|
38 | kind: Kind;
|
39 | help: string;
|
40 | customParams: CustomParams;
|
41 | }
|
42 |
|
43 | export interface MetricsMetaMap {
|
44 | [name: string]: MetricsMeta;
|
45 | }
|
46 |
|
47 | export type AuthTestFunc = (req: express.Request) => boolean;
|