UNPKG

@snap/camera-kit

Version:
26 lines 830 B
import { Metric, serializeMetricDimensions } from "./Metric"; export class Histogram extends Metric { static level(name, level, dimensions = {}) { const histogram = new Histogram(name, dimensions); histogram.add(level); return histogram; } constructor(name, dimensions = {}) { super(name, dimensions); this.name = name; this.levels = []; } add(level) { this.levels.push(level); } toOperationalMetric() { const timestamp = new Date(); const name = `${this.name}${serializeMetricDimensions(this.dimensions)}`; return this.levels.map((level) => ({ name, timestamp, metric: { $case: "histogram", histogram: `${Math.ceil(level)}` }, })); } } //# sourceMappingURL=Histogram.js.map