Skip to content

Commit

Permalink
fix: Add missing properties to metrics from abstract class Metric
Browse files Browse the repository at this point in the history
  • Loading branch information
kouak committed Nov 22, 2024
1 parent c1d76c5 commit 545e723
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,38 @@ export type Metric<T extends string = string> =
| Summary<T>
| Histogram<T>;

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<this>;
}

/**
* Aggregation methods, used for aggregating metrics in a Node.js cluster.
*/
Expand Down Expand Up @@ -251,7 +283,7 @@ export interface ObserveDataWithExemplar<T extends string> {
/**
* A counter is a cumulative metric that represents a single numerical value that only ever goes up
*/
export class Counter<T extends string = string> {
export class Counter<T extends string = string> extends AbstractMetric {
/**
* @param configuration Configuration when creating a Counter metric. Name and Help is required.
*/
Expand Down Expand Up @@ -331,7 +363,7 @@ export interface GaugeConfiguration<T extends string>
/**
* A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
*/
export class Gauge<T extends string = string> {
export class Gauge<T extends string = string> extends AbstractMetric {
/**
* @param configuration Configuration when creating a Gauge metric. Name and Help is mandatory
*/
Expand Down Expand Up @@ -472,7 +504,7 @@ export interface HistogramConfiguration<T extends string>
/**
* A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets
*/
export class Histogram<T extends string = string> {
export class Histogram<T extends string = string> extends AbstractMetric {
/**
* @param configuration Configuration when creating the Histogram. Name and Help is mandatory
*/
Expand Down Expand Up @@ -599,7 +631,7 @@ export interface SummaryConfiguration<T extends string>
/**
* A summary samples observations
*/
export class Summary<T extends string = string> {
export class Summary<T extends string = string> extends AbstractMetric {
/**
* @param configuration Configuration when creating Summary metric. Name and Help is mandatory
*/
Expand Down

0 comments on commit 545e723

Please sign in to comment.