summaryrefslogtreecommitdiff
path: root/u/trace/metric/emittable.ts
blob: f3441ec4fa984f64179b85d311fd87436f4dfea8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { IEmittableMetric, MetricValue, MetricValueTag, Unit } from './index.js';

export class EmittableMetric implements IEmittableMetric {
    constructor(
        public readonly name: string,
        public readonly unit: Unit,
    ) {}

    public withValue(value: number): MetricValue {
        return {
            name: this.name,
            unit: this.unit,
            emissionTimestamp: Date.now(),
            value,
            _tag: MetricValueTag,
        };
    }
}