@promster/types
Version:
Shared types of promster
46 lines (45 loc) • 1.7 kB
TypeScript
import { Counter, Gauge, Histogram, Summary } from "prom-client";
import { DeepRequired } from "ts-essentials";
//#region src/index.d.ts
type TLabelValues = Record<string, string | number>;
type TContext<Q, S> = {
req: Q;
res: S;
};
type TOptionalPromsterOptions = {
labels?: string[];
metricPrefix?: string;
metricTypes?: string[];
metricNames?: Record<string, string | string[]>;
normalizePath?: <Q, S>(path: string, context: TContext<Q, S>) => string;
normalizeStatusCode?: <Q, S>(code: number, context: TContext<Q, S>) => number;
normalizeMethod?: <Q, S>(method: string, context: TContext<Q, S>) => string;
getLabelValues?: <Q, S>(request: Q, response: S) => TLabelValues;
detectKubernetes?: boolean;
metricBuckets?: Record<string, number[]>;
metricPercentiles?: Record<string, number[]>;
disableGcMetrics?: boolean;
gcCollectionInterval?: number;
};
type TDefaultedPromsterOptions = DeepRequired<TOptionalPromsterOptions>;
type THttpMetrics = {
httpRequestDurationPerPercentileInSeconds?: Summary[];
httpRequestDurationInSeconds?: Histogram[];
httpRequestsTotal?: Counter[];
httpRequestContentLengthInBytes?: Histogram[];
httpResponseContentLengthInBytes?: Histogram[];
};
type TGcMetrics = {
up: Gauge[];
};
type TGraphQlMetrics = {
graphQlParseDuration?: Histogram[];
graphQlValidationDuration?: Histogram[];
graphQlResolveFieldDuration?: Histogram[];
graphQlRequestDuration?: Histogram[];
graphQlErrorsTotal?: Counter[];
};
type TValueOf<T> = T[keyof T];
//#endregion
export { TDefaultedPromsterOptions, TGcMetrics, TGraphQlMetrics, THttpMetrics, TLabelValues, TOptionalPromsterOptions, TValueOf };
//# sourceMappingURL=index.d.ts.map