Module: utils/recordMetric

Validation wrapper around metricSamplesRepo.insertSample (MET-001). Call this from any backend telemetry callsite that wants to emit a time-series sample without each callsite re-implementing the same input guards.

Designed as best-effort: silently skips invalid inputs (missing projectId / metricKey, or value that doesn't coerce to a finite number) rather than throwing. This is intentional — telemetry must never flip a passing run into a failing one. Callers are expected to wrap the call in a try/catch if they care about persistence failures (see backend/src/runner/healingPersistence.js for the canonical usage).

Source:

Methods

(static) recordMetric(projectId, metricKey, value, tagsopt, tsopt) → {void}

Record a single metric sample.

Coerces numeric strings (e.g. "7.5") via Number(), rejects NaN and missing identifiers. No-op on invalid input.

Parameters:
Name Type Attributes Default Description
projectId string
metricKey string

Stable metric identifier (e.g. "healing.savings", "webVitals.lcp").

value number | string

Numeric value or numeric string; coerced via Number().

tags Object | null <optional>
null

Optional structured context (e.g. { testId }).

ts number <optional>
Date.now()

Sample timestamp, epoch ms.

Source:
Returns:
Type
void