unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
35 lines • 1.64 kB
TypeScript
import { Gauge as PromGauge, type GaugeConfiguration } from 'prom-client';
/**
* A wrapped instance of prom-client's Gauge, overriding some of its methods for enhanced functionality and type-safety.
*/
export type Gauge<T extends string = string> = {
gauge: PromGauge<T>;
labels: (labels: Record<T, string | number>) => PromGauge.Internal<T>;
reset: () => void;
set: (value: number) => void;
};
/**
* Additional options for createGauge that allow registering a lazy collect function
* which caches values for a given TTL.
*/
export type CreateGaugeOptions<T extends string> = GaugeConfiguration<T> & {
/**
* Time to live for cached values in milliseconds. Used together with `fetchValue`.
*/
ttlMs?: number;
/**
* Optional fetcher used to populate the gauge value lazily on scrape.
* If provided together with `ttlMs`, a `collect` function will be installed that
* caches the value for the TTL. Return null to indicate unknown (we'll set NaN).
*/
fetchValue?: () => Promise<number | null>;
};
/**
* Creates a wrapped instance of prom-client's Gauge, overriding some of its methods for enhanced functionality and type-safety.
*
* @param options - The configuration options for the Gauge, as defined in prom-client's GaugeConfiguration.
* See prom-client documentation for detailed options: https://github.com/siimon/prom-client#gauge
* @returns An object containing the wrapped Gauge instance and custom methods.
*/
export declare const createGauge: <T extends string>(options: CreateGaugeOptions<T>) => Gauge<T>;
//# sourceMappingURL=createGauge.d.ts.map