/** * @since 1.0.0 */ import type * as Chunk from "@effect/data/Chunk" import type * as Duration from "@effect/data/Duration" import type * as Equal from "@effect/data/Equal" import type * as HashSet from "@effect/data/HashSet" import type * as Option from "@effect/data/Option" import type { Pipeable } from "@effect/data/Pipeable" import * as internal from "@effect/io/internal/metric/key" import type * as MetricBoundaries from "@effect/io/MetricBoundaries" import type * as MetricKeyType from "@effect/io/MetricKeyType" import type * as MetricLabel from "@effect/io/MetricLabel" /** * @since 1.0.0 * @category symbols */ export const MetricKeyTypeId: unique symbol = internal.MetricKeyTypeId /** * @since 1.0.0 * @category symbols */ export type MetricKeyTypeId = typeof MetricKeyTypeId /** * 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. * * @since 1.0.0 * @category models */ export interface MetricKey> extends MetricKey.Variance, Equal.Equal, Pipeable { readonly name: string readonly keyType: Type readonly description: Option.Option readonly tags: HashSet.HashSet } /** * @since 1.0.0 */ export declare namespace MetricKey { /** * @since 1.0.0 * @category models */ export type Untyped = MetricKey /** * @since 1.0.0 * @category models */ export type Counter = MetricKey /** * @since 1.0.0 * @category models */ export type Gauge = MetricKey /** * @since 1.0.0 * @category models */ export type Frequency = MetricKey /** * @since 1.0.0 * @category models */ export type Histogram = MetricKey /** * @since 1.0.0 * @category models */ export type Summary = MetricKey /** * @since 1.0.0 * @category models */ export interface Variance { readonly [MetricKeyTypeId]: { _Type: (_: never) => Type } } } /** * @since 1.0.0 * @category refinements */ export const isMetricKey: (u: unknown) => u is MetricKey> = internal.isMetricKey /** * Creates a metric key for a counter, with the specified name. * * @since 1.0.0 * @category constructors */ export const counter: (name: string, description?: string) => MetricKey.Counter = internal.counter /** * Creates a metric key for a categorical frequency table, with the specified * name. * * @since 1.0.0 * @category constructors */ export const frequency: (name: string, description?: string) => MetricKey.Frequency = internal.frequency /** * Creates a metric key for a gauge, with the specified name. * * @since 1.0.0 * @category constructors */ export const gauge: (name: string, description?: string) => MetricKey.Gauge = internal.gauge /** * Creates a metric key for a histogram, with the specified name and boundaries. * * @since 1.0.0 * @category constructors */ export const histogram: ( name: string, boundaries: MetricBoundaries.MetricBoundaries, description?: string ) => MetricKey.Histogram = internal.histogram /** * Creates a metric key for a summary, with the specified name, maxAge, * maxSize, error, and quantiles. * * @since 1.0.0 * @category constructors */ export const summary: ( options: { readonly name: string readonly maxAge: Duration.DurationInput readonly maxSize: number readonly error: number readonly quantiles: Chunk.Chunk readonly description?: string } ) => MetricKey.Summary = internal.summary /** * Returns a new `MetricKey` with the specified tag appended. * * @since 1.0.0 * @category constructors */ export const tagged: { ( key: string, value: string ): >(self: MetricKey) => MetricKey >( self: MetricKey, key: string, value: string ): MetricKey } = internal.tagged /** * Returns a new `MetricKey` with the specified tags appended. * * @since 1.0.0 * @category constructors */ export const taggedWithLabels: { ( extraTags: Iterable ): >(self: MetricKey) => MetricKey >( self: MetricKey, extraTags: Iterable ): MetricKey } = internal.taggedWithLabels /** * Returns a new `MetricKey` with the specified tags appended. * * @since 1.0.0 * @category constructors */ export const taggedWithLabelSet: { ( extraTags: HashSet.HashSet ): >(self: MetricKey) => MetricKey >( self: MetricKey, extraTags: HashSet.HashSet ): MetricKey } = internal.taggedWithLabelSet