summaryrefslogtreecommitdiff
path: root/u/trace/metric/metric.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-07-27 18:50:33 -0700
committerElizabeth Hunt <me@liz.coffee>2025-07-27 19:31:06 -0700
commit7aa11b7a8abacf81dec20fff21216df35d333756 (patch)
tree40f6a76c37412cf1c5a67f99a4ee30e3aae863c9 /u/trace/metric/metric.ts
parente4df72cd446270cf867ec308995a05e21b3aa601 (diff)
downloadci-7aa11b7a8abacf81dec20fff21216df35d333756.tar.gz
ci-7aa11b7a8abacf81dec20fff21216df35d333756.zip
Pulls in pengueno from npm
Diffstat (limited to 'u/trace/metric/metric.ts')
-rw-r--r--u/trace/metric/metric.ts54
1 files changed, 0 insertions, 54 deletions
diff --git a/u/trace/metric/metric.ts b/u/trace/metric/metric.ts
deleted file mode 100644
index 8ef339f..0000000
--- a/u/trace/metric/metric.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { EmittableMetric, IMetric, IMetricTag, IResultMetric, Unit } from './index.js';
-
-class _Tagged {
- protected constructor(public readonly _tag = IMetricTag) {}
-}
-
-export class Metric extends _Tagged implements IMetric {
- private static DELIM = '.';
-
- protected constructor(
- public readonly name: string,
- public readonly parent: undefined | IMetric = undefined,
- public readonly count = new EmittableMetric(Metric.join(name, 'count'), Unit.COUNT),
- public readonly time = new EmittableMetric(Metric.join(name, 'time'), Unit.MILLISECONDS),
- ) {
- super();
- }
-
- public child(_name: string): Metric {
- const childName = Metric.join(this.name, _name);
- return new Metric(childName, this);
- }
-
- public asResult() {
- return ResultMetric.from(this);
- }
-
- static join(...name: Array<string>) {
- return name.join(Metric.DELIM);
- }
-
- static fromName(name: string): Metric {
- return new Metric(name);
- }
-}
-
-export class ResultMetric extends Metric implements IResultMetric {
- protected constructor(
- public readonly name: string,
- public readonly parent: undefined | IMetric = undefined,
- public readonly failure: IMetric,
- public readonly success: IMetric,
- public readonly warn: IMetric,
- ) {
- super(name, parent);
- }
-
- static from(metric: Metric) {
- const failure = metric.child('failure');
- const success = metric.child('success');
- const warn = metric.child('warn');
- return new ResultMetric(metric.name, metric.parent, failure, success, warn);
- }
-}