mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-19 01:17:18 +02:00
## About the changes - Adds createHistogram - Adds histogram metrics for proxy-repositorys loading features
28 lines
697 B
TypeScript
28 lines
697 B
TypeScript
import {
|
|
Histogram as PromHistogram,
|
|
HistogramConfiguration,
|
|
} from 'prom-client';
|
|
|
|
export type Histogram<T extends string = string> = {
|
|
histogram: PromHistogram<T>;
|
|
labels: (labels: Record<T, string | number>) => PromHistogram.Internal<T>;
|
|
observe: (value: number) => void;
|
|
};
|
|
|
|
export const createHistogram = <T extends string>(
|
|
options: HistogramConfiguration<T>,
|
|
): Histogram<T> => {
|
|
const histogram = new PromHistogram(options);
|
|
|
|
const labels = (labels: Record<T, string | number>) =>
|
|
histogram.labels(labels);
|
|
|
|
const observe = (value: number) => histogram.observe(value);
|
|
|
|
return {
|
|
histogram,
|
|
labels,
|
|
observe,
|
|
};
|
|
};
|