Skip to content

Commit

Permalink
feat(types): add default types to metrics types (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanYar committed Aug 22, 2022
1 parent a6d4700 commit a33d294
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class AggregatorRegistry extends Registry {
/**
* General metric type
*/
export type Metric<T extends string> =
export type Metric<T extends string = string> =
| Counter<T>
| Gauge<T>
| Summary<T>
Expand Down Expand Up @@ -163,7 +163,7 @@ export interface CounterConfiguration<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> {
export class Counter<T extends string = string> {
/**
* @param configuration Configuration when creating a Counter metric. Name and Help is required.
*/
Expand Down Expand Up @@ -232,7 +232,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> {
export class Gauge<T extends string = string> {
/**
* @param configuration Configuration when creating a Gauge metric. Name and Help is mandatory
*/
Expand Down Expand Up @@ -368,7 +368,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> {
export class Histogram<T extends string = string> {
/**
* @param configuration Configuration when creating the Histogram. Name and Help is mandatory
*/
Expand Down Expand Up @@ -470,7 +470,7 @@ export interface SummaryConfiguration<T extends string>
/**
* A summary samples observations
*/
export class Summary<T extends string> {
export class Summary<T extends string = string> {
/**
* @param configuration Configuration when creating Summary metric. Name and Help is mandatory
*/
Expand Down Expand Up @@ -571,23 +571,23 @@ export class Pushgateway {
*/
pushAdd(
params: Pushgateway.Parameters,
): Promise<{ resp?: unknown, body?: unknown }>;
): Promise<{ resp?: unknown; body?: unknown }>;

/**
* Overwrite all metric (using PUT to Pushgateway)
* @param params Push parameters
*/
push(
params: Pushgateway.Parameters,
): Promise<{ resp?: unknown, body?: unknown }>;
): Promise<{ resp?: unknown; body?: unknown }>;

/**
* Delete all metrics for jobName
* @param params Push parameters
*/
delete(
params: Pushgateway.Parameters,
): Promise<{ resp?: unknown, body?: unknown }>;
): Promise<{ resp?: unknown; body?: unknown }>;
}

export namespace Pushgateway {
Expand Down

0 comments on commit a33d294

Please sign in to comment.