summaryrefslogtreecommitdiff
path: root/lib/trace/metric/emittable.ts
blob: 232cd3a7a5b1e0a738c9faf8c3bdd658378f5408 (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 '.';

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,
        };
    }
}