import {Histogram, Tags, HistogramFactory} from '@btilford/ts-base-core';
import {StatsDMetric, StatsDOptions} from './metric';
class StatsDHistogram extends StatsDMetric implements Histogram<number> {
set(value: number, tags: Tags = {}): void {
this.statsd.histogram(
this.name,
value,
this.options.sampleRate,
{
...this.tags,
...tags,
},
);
}
}
export class StatsDHistogramFactory extends HistogramFactory<number> {
protected readonly options: StatsDOptions;
constructor(options: StatsDOptions = {}) {
super();
this.options = { ...options };
}
histogram(name: string, tags: Tags = {}): Histogram<number> {
return new StatsDHistogram(name, this.options, tags);
}
}
|