diff --git a/index.d.ts b/index.d.ts index 1fd1eac9..cbc54e80 100644 --- a/index.d.ts +++ b/index.d.ts @@ -180,6 +180,38 @@ export type Metric = | Summary | Histogram; +declare abstract class AbstractMetric { + /** + * The name of the metric. + */ + readonly name: string; + + /** + * The help text of the metric. + */ + readonly help: string; + + /** + * List of registers attached to the metric. + */ + readonly registers: readonly Registry[]; + + /** + * List of label names attached to the metric. + */ + readonly labelNames: readonly string[]; + + /** + * The aggregation method used for aggregating this metric in a Node.js cluster. + */ + readonly aggregator: Aggregator; + + /** + * If provided, the collect function of the metric, which is invoked on each scrape. + */ + readonly collect?: CollectFunction; +} + /** * Aggregation methods, used for aggregating metrics in a Node.js cluster. */ @@ -251,7 +283,7 @@ export interface ObserveDataWithExemplar { /** * A counter is a cumulative metric that represents a single numerical value that only ever goes up */ -export class Counter { +export class Counter extends AbstractMetric { /** * @param configuration Configuration when creating a Counter metric. Name and Help is required. */ @@ -331,7 +363,7 @@ export interface GaugeConfiguration /** * A gauge is a metric that represents a single numerical value that can arbitrarily go up and down. */ -export class Gauge { +export class Gauge extends AbstractMetric { /** * @param configuration Configuration when creating a Gauge metric. Name and Help is mandatory */ @@ -472,7 +504,7 @@ export interface HistogramConfiguration /** * A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets */ -export class Histogram { +export class Histogram extends AbstractMetric { /** * @param configuration Configuration when creating the Histogram. Name and Help is mandatory */ @@ -599,7 +631,7 @@ export interface SummaryConfiguration /** * A summary samples observations */ -export class Summary { +export class Summary extends AbstractMetric { /** * @param configuration Configuration when creating Summary metric. Name and Help is mandatory */