Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(types): add default types to metrics types #505

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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