Skip to content

Commit a33d294

Browse files
authored
feat(types): add default types to metrics types (#505)
1 parent a6d4700 commit a33d294

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
### Changed
1313

14+
- types: converted all the generic Metric types to be optional
15+
1416
- The `done()` functions returned by `gauge.startTimer()` and
1517
`summary.startTimer()` now return the timed duration. Histograms already had
1618
this behavior.

index.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class AggregatorRegistry extends Registry {
116116
/**
117117
* General metric type
118118
*/
119-
export type Metric<T extends string> =
119+
export type Metric<T extends string = string> =
120120
| Counter<T>
121121
| Gauge<T>
122122
| Summary<T>
@@ -163,7 +163,7 @@ export interface CounterConfiguration<T extends string>
163163
/**
164164
* A counter is a cumulative metric that represents a single numerical value that only ever goes up
165165
*/
166-
export class Counter<T extends string> {
166+
export class Counter<T extends string = string> {
167167
/**
168168
* @param configuration Configuration when creating a Counter metric. Name and Help is required.
169169
*/
@@ -232,7 +232,7 @@ export interface GaugeConfiguration<T extends string>
232232
/**
233233
* A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
234234
*/
235-
export class Gauge<T extends string> {
235+
export class Gauge<T extends string = string> {
236236
/**
237237
* @param configuration Configuration when creating a Gauge metric. Name and Help is mandatory
238238
*/
@@ -368,7 +368,7 @@ export interface HistogramConfiguration<T extends string>
368368
/**
369369
* A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets
370370
*/
371-
export class Histogram<T extends string> {
371+
export class Histogram<T extends string = string> {
372372
/**
373373
* @param configuration Configuration when creating the Histogram. Name and Help is mandatory
374374
*/
@@ -470,7 +470,7 @@ export interface SummaryConfiguration<T extends string>
470470
/**
471471
* A summary samples observations
472472
*/
473-
export class Summary<T extends string> {
473+
export class Summary<T extends string = string> {
474474
/**
475475
* @param configuration Configuration when creating Summary metric. Name and Help is mandatory
476476
*/
@@ -571,23 +571,23 @@ export class Pushgateway {
571571
*/
572572
pushAdd(
573573
params: Pushgateway.Parameters,
574-
): Promise<{ resp?: unknown, body?: unknown }>;
574+
): Promise<{ resp?: unknown; body?: unknown }>;
575575

576576
/**
577577
* Overwrite all metric (using PUT to Pushgateway)
578578
* @param params Push parameters
579579
*/
580580
push(
581581
params: Pushgateway.Parameters,
582-
): Promise<{ resp?: unknown, body?: unknown }>;
582+
): Promise<{ resp?: unknown; body?: unknown }>;
583583

584584
/**
585585
* Delete all metrics for jobName
586586
* @param params Push parameters
587587
*/
588588
delete(
589589
params: Pushgateway.Parameters,
590-
): Promise<{ resp?: unknown, body?: unknown }>;
590+
): Promise<{ resp?: unknown; body?: unknown }>;
591591
}
592592

593593
export namespace Pushgateway {

0 commit comments

Comments
 (0)