From 6d73509f9cef1caef75bd4d15cb1f76ad809be00 Mon Sep 17 00:00:00 2001 From: RomanYar Date: Tue, 21 Jun 2022 13:45:23 +0300 Subject: [PATCH 1/2] feat(types): add default types to metrics types --- index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3c60f643..a99bcd0c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -116,7 +116,7 @@ export class AggregatorRegistry extends Registry { /** * General metric type */ -export type Metric = +export type Metric = | Counter | Gauge | Summary @@ -163,7 +163,7 @@ export interface CounterConfiguration /** * A counter is a cumulative metric that represents a single numerical value that only ever goes up */ -export class Counter { +export class Counter { /** * @param configuration Configuration when creating a Counter metric. Name and Help is required. */ @@ -232,7 +232,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 { /** * @param configuration Configuration when creating a Gauge metric. Name and Help is mandatory */ @@ -368,7 +368,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 { /** * @param configuration Configuration when creating the Histogram. Name and Help is mandatory */ @@ -470,7 +470,7 @@ export interface SummaryConfiguration /** * A summary samples observations */ -export class Summary { +export class Summary { /** * @param configuration Configuration when creating Summary metric. Name and Help is mandatory */ @@ -571,7 +571,7 @@ export class Pushgateway { */ pushAdd( params: Pushgateway.Parameters, - ): Promise<{ resp?: unknown, body?: unknown }>; + ): Promise<{ resp?: unknown; body?: unknown }>; /** * Overwrite all metric (using PUT to Pushgateway) @@ -579,7 +579,7 @@ export class Pushgateway { */ push( params: Pushgateway.Parameters, - ): Promise<{ resp?: unknown, body?: unknown }>; + ): Promise<{ resp?: unknown; body?: unknown }>; /** * Delete all metrics for jobName @@ -587,7 +587,7 @@ export class Pushgateway { */ delete( params: Pushgateway.Parameters, - ): Promise<{ resp?: unknown, body?: unknown }>; + ): Promise<{ resp?: unknown; body?: unknown }>; } export namespace Pushgateway { From 7b2e3f69941aef9e0182fcda65916167c4074365 Mon Sep 17 00:00:00 2001 From: RomanYar Date: Tue, 21 Jun 2022 13:51:30 +0300 Subject: [PATCH 2/2] added a changelog message --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ac13a33..9a3e4f38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Changed +- types: converted all the generic Metric types to be optional + - The `done()` functions returned by `gauge.startTimer()` and `summary.startTimer()` now return the timed duration. Histograms already had this behavior.