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

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