zibri
    Preparing search index...

    Interface for a metrics service.

    interface MetricsServiceInterface {
        attachTo: (app: ZibriApplication) => void | Promise<void>;
        collect: () => Promise<void>;
        getCounter: (
            name: CounterMetricName,
            labelNames?: string[],
        ) => CounterInterface;
        getGauge: (name: string, labelNames?: string[]) => GaugeInterface;
        getHistogram: (
            name: HistogramMetricName,
            labelNames?: string[],
            buckets?: number[],
        ) => HistogramInterface;
        getMetricSnapshots: () => MetricsSnapshot[];
        measureFinishedRequest: (
            req: HttpRequest,
            res: HttpResponse,
            durationInMs: number,
        ) => void | Promise<void>;
    }

    Implemented by

    Index

    Properties

    attachTo: (app: ZibriApplication) => void | Promise<void>

    Attaches the service to the Zibri application.

    collect: () => Promise<void>

    Collect a snapshot of every metric’s current samples. This will usually be called in regular intervals, eg. From a cron job.

    To retrieve the metrics use the getMetrics method.

    getCounter: (name: CounterMetricName, labelNames?: string[]) => CounterInterface

    Create or retrieve a counter metric.

    getGauge: (name: string, labelNames?: string[]) => GaugeInterface

    Create or retrieve a gauge metric.

    getHistogram: (
        name: HistogramMetricName,
        labelNames?: string[],
        buckets?: number[],
    ) => HistogramInterface

    Create or retrieve a histogram metric.

    getMetricSnapshots: () => MetricsSnapshot[]

    Returns all 60 buffered snapshots.

    IF YOU WANT A LONGER HISTORY YOU SHOULD USE AN EXTERNAL TOOL LIKE PROMETHEUS TO SCRAPE THE DATA.

    measureFinishedRequest: (
        req: HttpRequest,
        res: HttpResponse,
        durationInMs: number,
    ) => void | Promise<void>

    Collects metrics about a finished request.