Skip to content

MetricKey

12 exports Added in v2.0.0 Source

Constructors

counter

Added in v2.0.0 Source

Creates a metric key for a counter, with the specified name.

Signature

declare const counter: {
  (
    name: string,
    options?: {
      readonly bigint?: false;
      readonly description?: string;
      readonly incremental?: boolean;
    },
  ): Counter<number>;
  (
    name: string,
    options: {
      readonly bigint: true;
      readonly description?: string;
      readonly incremental?: boolean;
    },
  ): Counter<bigint>;
};

frequency

Added in v2.0.0 Source

Creates a metric key for a categorical frequency table, with the specified name.

Signature

declare const frequency: (
  name: string,
  options?: {
    readonly description?: string;
    readonly preregisteredWords?: ReadonlyArray<string>;
  },
) => MetricKey.Frequency;

gauge

Added in v2.0.0 Source

Creates a metric key for a gauge, with the specified name.

Signature

declare const gauge: {
  (
    name: string,
    options?: {
      readonly bigint?: false;
      readonly description?: string;
    },
  ): Gauge<number>;
  (
    name: string,
    options: {
      readonly bigint: true;
      readonly description?: string;
    },
  ): Gauge<bigint>;
};

histogram

Added in v2.0.0 Source

Creates a metric key for a histogram, with the specified name and boundaries.

Signature

declare const histogram: (
  name: string,
  boundaries: MetricBoundaries.MetricBoundaries,
  description?: string,
) => MetricKey.Histogram;

summary

Added in v2.0.0 Source

Creates a metric key for a summary, with the specified name, maxAge, maxSize, error, and quantiles.

Signature

declare const summary: (options: {
  readonly description?: string;
  readonly error: number;
  readonly maxAge: Duration.DurationInput;
  readonly maxSize: number;
  readonly name: string;
  readonly quantiles: ReadonlyArray<number>;
}) => MetricKey.Summary;

tagged

Added in v2.0.0 Source

Returns a new MetricKey with the specified tag appended.

Signature

declare const tagged: {
  (
    key: string,
    value: string,
  ): <Type extends MetricKeyType<any, any>>(self: MetricKey<Type>) => MetricKey<Type>;
  <Type extends MetricKeyType<any, any>>(
    self: MetricKey<Type>,
    key: string,
    value: string,
  ): MetricKey<Type>;
};

Returns a new MetricKey with the specified tags appended.

Signature

declare const taggedWithLabels: {
  (extraTags: readonly Array<MetricLabel>): <Type extends MetricKeyType<any, any>>(self: MetricKey<Type>) => MetricKey<Type>;
  <Type extends MetricKeyType<any, any>>(self: MetricKey<Type>, extraTags: readonly Array<MetricLabel>): MetricKey<Type>;
}

Models

MetricKey interface

Added in v2.0.0 Source

A MetricKey is a unique key associated with each metric. The key is based on a combination of the metric type, the name and tags associated with the metric, an optional description of the key, and any other information to describe a metric, such as the boundaries of a histogram. In this way, it is impossible to ever create different metrics with conflicting keys.

Signature

interface MetricKey<out Type extends MetricKeyType.MetricKeyType<any, any>> extends Variance<Type>, Equal, Pipeable {
  readonly description: Option<string>;
  readonly keyType: Type;
  readonly name: string;
  readonly tags: readonly Array<MetricLabel>;
}

Other

MetricKey

Added in v2.0.0 Source

Refinements

isMetricKey

Added in v2.0.0 Source

Signature

declare const isMetricKey: (
  u: unknown,
) => u is MetricKey<MetricKeyType.MetricKeyType<unknown, unknown>>;

Symbols

Signature

declare const MetricKeyTypeId: unique symbol;

MetricKeyTypeId type

Added in v2.0.0 Source

Signature

type MetricKeyTypeId = typeof MetricKeyTypeId;