diff --git a/index.d.ts b/index.d.ts index a99bcd0c..ec99f53d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -29,12 +29,12 @@ export class Registry { /** * Get all metrics as objects */ - getMetricsAsJSON(): Promise; + getMetricsAsJSON(): Promise>[]>; /** * Get all metrics as objects */ - getMetricsAsArray(): metric[]; + getMetricsAsArray(): MetricObject[]; /** * Remove a single metric @@ -136,7 +136,7 @@ export enum MetricType { type CollectFunction = (this: T) => void | Promise; -interface metric { +interface MetricObject { name: string; help: string; type: MetricType; @@ -144,6 +144,20 @@ interface metric { collect: CollectFunction; } +interface MetricObjectWithValues> + extends MetricObject { + values: T[]; +} + +type MetricValue = { + value: number; + labels: LabelValues; +}; + +type MetricValueWithName = MetricValue & { + metricName: string; +}; + type LabelValues = Partial>; interface MetricConfiguration { @@ -182,6 +196,11 @@ export class Counter { */ inc(value?: number): void; + /** + * Get counter metric object + */ + get(): Promise>>; + /** * Return the child for given labels * @param values Label values @@ -277,6 +296,11 @@ export class Gauge { */ set(value: number): void; + /** + * Get gauge metric object + */ + get(): Promise>>; + /** * Set gauge value to current epoch time in ms * @param labels Object with label keys and values @@ -386,6 +410,11 @@ export class Histogram { */ observe(labels: LabelValues, value: number): void; + /** + * Get histogram metric object + */ + get(): Promise>>; + /** * Start a timer. Calling the returned function will observe the duration in * seconds in the histogram. @@ -488,6 +517,11 @@ export class Summary { */ observe(labels: LabelValues, value: number): void; + /** + * Get summary metric object + */ + get(): Promise>>; + /** * Start a timer. Calling the returned function will observe the duration in * seconds in the summary.