Initial Commit

This commit is contained in:
2026-05-27 23:47:53 +01:00
parent fbc70f96e6
commit 9b28db724f
18103 changed files with 1600554 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import type { Counter, Histogram } from "@opentelemetry/api";
import { metrics } from "@opentelemetry/api";
const METRIC_CONVERT_TOTAL = "emblem_solver.convert.total";
const METRIC_CONVERT_DURATION = "emblem_solver.convert.duration_ms";
let convertCounter: Counter | undefined;
let convertDuration: Histogram | undefined;
/** Lazy access to the `convert.total` counter. */
export function getConvertCounter(): Counter {
if (!convertCounter) {
const meter = metrics.getMeter("@suaveplan/emblem-solver");
convertCounter = meter.createCounter(METRIC_CONVERT_TOTAL, {
description: "Total number of convert() invocations",
});
}
return convertCounter;
}
/** Lazy access to the `convert.duration_ms` histogram. */
export function getConvertDuration(): Histogram {
if (!convertDuration) {
const meter = metrics.getMeter("@suaveplan/emblem-solver");
convertDuration = meter.createHistogram(METRIC_CONVERT_DURATION, {
description: "Duration of convert() in milliseconds",
unit: "ms",
});
}
return convertDuration;
}
/** Internal test helper: reset the cached instruments. */
export function __resetTelemetryForTests(): void {
convertCounter = undefined;
convertDuration = undefined;
}
/** Internal test helper: query the cached instruments. */
export function __peekTelemetryForTests(): {
counter: Counter | undefined;
histogram: Histogram | undefined;
} {
return { counter: convertCounter, histogram: convertDuration };
}