/** * @since 1.0.0 */ import type * as Chunk from "@effect/data/Chunk"; import type * as Duration from "@effect/data/Duration"; import type { LazyArg } from "@effect/data/Function"; import type * as HashSet from "@effect/data/HashSet"; import type { Pipeable } from "@effect/data/Pipeable"; import type * as Effect from "@effect/io/Effect"; import type * as MetricBoundaries from "@effect/io/MetricBoundaries"; import type * as MetricKey from "@effect/io/MetricKey"; import type * as MetricKeyType from "@effect/io/MetricKeyType"; import type * as MetricLabel from "@effect/io/MetricLabel"; import type * as MetricPair from "@effect/io/MetricPair"; import type * as MetricRegistry from "@effect/io/MetricRegistry"; import type * as MetricState from "@effect/io/MetricState"; /** * @since 1.0.0 * @category symbols */ export declare const MetricTypeId: unique symbol; /** * @since 1.0.0 * @category symbols */ export type MetricTypeId = typeof MetricTypeId; /** * A `Metric` represents a concurrent metric which accepts * updates of type `In` and are aggregated to a stateful value of type `Out`. * * For example, a counter metric would have type `Metric`, * representing the fact that the metric can be updated with numbers (the amount * to increment or decrement the counter by), and the state of the counter is a * number. * * There are five primitive metric types supported by Effect: * * - Counters * - Frequencies * - Gauges * - Histograms * - Summaries * * @since 1.0.0 * @category models */ export interface Metric extends Metric.Variance, Pipeable { /** * The type of the underlying primitive metric. For example, this could be * `MetricKeyType.Counter` or `MetricKeyType.Gauge`. */ readonly keyType: Type; readonly unsafeUpdate: (input: In, extraTags: HashSet.HashSet) => void; readonly unsafeValue: (extraTags: HashSet.HashSet) => Out; /** */ (effect: Effect.Effect): Effect.Effect; } /** * @since 1.0.0 * @category models */ export interface MetricApply { (keyType: Type, unsafeUpdate: (input: In, extraTags: HashSet.HashSet) => void, unsafeValue: (extraTags: HashSet.HashSet) => Out): Metric; } /** * @since 1.0.0 */ export declare namespace Metric { /** * @since 1.0.0 * @category models */ interface Counter extends Metric { } /** * @since 1.0.0 * @category models */ interface Gauge extends Metric { } /** * @since 1.0.0 * @category models */ interface Frequency extends Metric { } /** * @since 1.0.0 * @category models */ interface Histogram extends Metric { } /** * @since 1.0.0 * @category models */ interface Summary extends Metric { } /** * @since 1.0.0 * @category models */ interface Variance { readonly [MetricTypeId]: { readonly _Type: (_: Type) => Type; readonly _In: (_: In) => void; readonly _Out: (_: never) => Out; }; } } /** * @since 1.0.0 * @category globals */ export declare const globalMetricRegistry: MetricRegistry.MetricRegistry; /** * @since 1.0.0 * @category constructors */ export declare const make: MetricApply; /** * Returns a new metric that is powered by this one, but which accepts updates * of the specified new type, which must be transformable to the input type of * this metric. * * @since 1.0.0 * @category mapping */ export declare const mapInput: { (f: (input: In2) => In): (self: Metric) => Metric; (self: Metric, f: (input: In2) => In): Metric; }; /** * A counter, which can be incremented by numbers. * * @since 1.0.0 * @category constructors */ export declare const counter: (name: string, description?: string) => Metric.Counter; /** * A string histogram metric, which keeps track of the counts of different * strings. * * @since 1.0.0 * @category constructors */ export declare const frequency: (name: string, description?: string) => Metric.Frequency; /** * Returns a new metric that is powered by this one, but which accepts updates * of any type, and translates them to updates with the specified constant * update value. * * @since 1.0.0 * @category constructors */ export declare const withConstantInput: { (input: In): (self: Metric) => Metric; (self: Metric, input: In): Metric; }; /** * @since 1.0.0 * @category constructors */ export declare const fromMetricKey: >(key: MetricKey.MetricKey) => Metric, MetricKeyType.MetricKeyType.OutType>; /** * A gauge, which can be set to a value. * * @since 1.0.0 * @category constructors */ export declare const gauge: (name: string, description?: string) => Metric.Gauge; /** * A numeric histogram metric, which keeps track of the count of numbers that * fall in bins with the specified boundaries. * * @since 1.0.0 * @category constructors */ export declare const histogram: (name: string, boundaries: MetricBoundaries.MetricBoundaries, description?: string) => Metric; /** * @since 1.0.0 * @category aspects */ export declare const increment: (self: Metric.Counter) => Effect.Effect; /** * @since 1.0.0 * @category aspects */ export declare const incrementBy: { (amount: number): (self: Metric.Counter) => Effect.Effect; (self: Metric.Counter, amount: number): Effect.Effect; }; /** * Returns a new metric that is powered by this one, but which outputs a new * state type, determined by transforming the state type of this metric by the * specified function. * * @since 1.0.0 * @category mapping */ export declare const map: { (f: (out: Out) => Out2): (self: Metric) => Metric; (self: Metric, f: (out: Out) => Out2): Metric; }; /** * @since 1.0.0 * @category mapping */ export declare const mapType: { (f: (type: Type) => Type2): (self: Metric) => Metric; (self: Metric, f: (type: Type) => Type2): Metric; }; /** * @since 1.0.0 * @category aspects */ export declare const set: { (value: In): (self: Metric.Gauge) => Effect.Effect; (self: Metric.Gauge, value: In): Effect.Effect; }; /** * Captures a snapshot of all metrics recorded by the application. * * @since 1.0.0 * @category getters */ export declare const snapshot: Effect.Effect>; /** * Creates a metric that ignores input and produces constant output. * * @since 1.0.0 * @category constructors */ export declare const succeed: (out: Out) => Metric; /** * Creates a metric that ignores input and produces constant output. * * @since 1.0.0 * @category constructors */ export declare const sync: (evaluate: LazyArg) => Metric; /** * @since 1.0.0 * @category constructors */ export declare const summary: (options: { readonly name: string; readonly maxAge: Duration.DurationInput; readonly maxSize: number; readonly error: number; readonly quantiles: Chunk.Chunk; readonly description?: string; }) => Metric.Summary; /** * @since 1.0.0 * @category constructors */ export declare const summaryTimestamp: (options: { readonly name: string; readonly maxAge: Duration.DurationInput; readonly maxSize: number; readonly error: number; readonly quantiles: Chunk.Chunk; readonly description?: string; }) => Metric.Summary; /** * Returns a new metric, which is identical in every way to this one, except * the specified tags have been added to the tags of this metric. * * @since 1.0.0 * @category utils */ export declare const tagged: { (key: string, value: string): (self: Metric) => Metric; (self: Metric, key: string, value: string): Metric; }; /** * Returns a new metric, which is identical in every way to this one, except * dynamic tags are added based on the update values. Note that the metric * returned by this method does not return any useful information, due to the * dynamic nature of the added tags. * * @since 1.0.0 * @category utils */ export declare const taggedWithLabelsInput: { (f: (input: In) => Iterable): (self: Metric) => Metric; (self: Metric, f: (input: In) => Iterable): Metric; }; /** * Returns a new metric, which is identical in every way to this one, except * the specified tags have been added to the tags of this metric. * * @since 1.0.0 * @category utils */ export declare const taggedWithLabels: { (extraTags: Iterable): (self: Metric) => Metric; (self: Metric, extraTags: Iterable): Metric; }; /** * Creates a timer metric, based on a histogram, which keeps track of * durations in milliseconds. The unit of time will automatically be added to * the metric as a tag (i.e. `"time_unit: milliseconds"`). * * @since 1.0.0 * @category constructors */ export declare const timer: (name: string) => Metric; /** * Creates a timer metric, based on a histogram created from the provided * boundaries, which keeps track of durations in milliseconds. The unit of time * will automatically be added to the metric as a tag (i.e. * `"time_unit: milliseconds"`). * * @since 1.0.0 * @category constructors */ export declare const timerWithBoundaries: (name: string, boundaries: Chunk.Chunk) => Metric; /** * Returns an aspect that will update this metric with the specified constant * value every time the aspect is applied to an effect, regardless of whether * that effect fails or succeeds. * * @since 1.0.0 * @category aspects */ export declare const trackAll: { (input: In): (self: Metric) => (effect: Effect.Effect) => Effect.Effect; (self: Metric, input: In): (effect: Effect.Effect) => Effect.Effect; }; /** * Returns an aspect that will update this metric with the defects of the * effects that it is applied to. * * @since 1.0.0 * @category aspects */ export declare const trackDefect: { (metric: Metric): (self: Effect.Effect) => Effect.Effect; (self: Effect.Effect, metric: Metric): Effect.Effect; }; /** * Returns an aspect that will update this metric with the result of applying * the specified function to the defect throwables of the effects that the * aspect is applied to. * * @since 1.0.0 * @category aspects */ export declare const trackDefectWith: { (metric: Metric, f: (defect: unknown) => In): (self: Effect.Effect) => Effect.Effect; (self: Effect.Effect, metric: Metric, f: (defect: unknown) => In): Effect.Effect; }; /** * Returns an aspect that will update this metric with the duration that the * effect takes to execute. To call this method, the input type of the metric * must be `Duration`. * * @since 1.0.0 * @category aspects */ export declare const trackDuration: { (metric: Metric): (self: Effect.Effect) => Effect.Effect; (self: Effect.Effect, metric: Metric): Effect.Effect; }; /** * Returns an aspect that will update this metric with the duration that the * effect takes to execute. To call this method, you must supply a function * that can convert the `Duration` to the input type of this metric. * * @since 1.0.0 * @category aspects */ export declare const trackDurationWith: { (metric: Metric, f: (duration: Duration.Duration) => In): (effect: Effect.Effect) => Effect.Effect; (self: Effect.Effect, metric: Metric, f: (duration: Duration.Duration) => In): Effect.Effect; }; /** * Returns an aspect that will update this metric with the failure value of * the effects that it is applied to. * * @since 1.0.0 * @category aspects */ export declare const trackError: { (metric: Metric): (self: Effect.Effect) => Effect.Effect; (self: Effect.Effect, metric: Metric): Effect.Effect; }; /** * Returns an aspect that will update this metric with the result of applying * the specified function to the error value of the effects that the aspect is * applied to. * * @since 1.0.0 * @category aspects */ export declare const trackErrorWith: { (metric: Metric, f: (error: In2) => In): (effect: Effect.Effect) => Effect.Effect; (self: Effect.Effect, metric: Metric, f: (error: In2) => In): Effect.Effect; }; /** * Returns an aspect that will update this metric with the success value of * the effects that it is applied to. * * @since 1.0.0 * @category aspects */ export declare const trackSuccess: { (metric: Metric): (self: Effect.Effect) => Effect.Effect; (self: Effect.Effect, metric: Metric): Effect.Effect; }; /** * Returns an aspect that will update this metric with the result of applying * the specified function to the success value of the effects that the aspect is * applied to. * * @since 1.0.0 * @category aspects */ export declare const trackSuccessWith: { (metric: Metric, f: (value: In2) => In): (self: Effect.Effect) => Effect.Effect; (self: Effect.Effect, metric: Metric, f: (value: In2) => In): Effect.Effect; }; /** * Updates the metric with the specified update message. For example, if the * metric were a counter, the update would increment the method by the * provided amount. * * @since 1.0.0 * @category utils */ export declare const update: { (input: In): (self: Metric) => Effect.Effect; (self: Metric, input: In): Effect.Effect; }; /** * Retrieves a snapshot of the value of the metric at this moment in time. * * @since 1.0.0 * @category getters */ export declare const value: (self: Metric) => Effect.Effect; /** * @since 1.0.0 * @category utils */ export declare const withNow: (self: Metric) => Metric; /** * @since 1.0.0 * @category zipping */ export declare const zip: { (that: Metric): (self: Metric) => Metric; (self: Metric, that: Metric): Metric; }; /** * Unsafely captures a snapshot of all metrics recorded by the application. * * @since 1.0.0 * @category unsafe */ export declare const unsafeSnapshot: (_: void) => HashSet.HashSet; /** * @since 1.0.0 * @category metrics */ export declare const fiberStarted: Metric.Counter; /** * @since 1.0.0 * @category metrics */ export declare const fiberSuccesses: Metric.Counter; /** * @since 1.0.0 * @category metrics */ export declare const fiberFailures: Metric.Counter; /** * @since 1.0.0 * @category metrics */ export declare const fiberLifetimes: Metric; /** * @since 1.0.0 * @category metrics */ export declare const fiberActive: Metric.Counter; //# sourceMappingURL=Metric.d.ts.map