autotel
Version:
Write Once, Observe Anywhere
41 lines (39 loc) • 2.11 kB
TypeScript
/**
* Validation telemetry wire constants — the single source of truth for the
* `validation.*` span attributes and the `autotel.validation.mismatches` metric
* emitted when an input payload (HTTP body, event, message) fails to match its
* declared shape.
*
* Dependency-free and side-effect-free by design (mirrors `security-schema.ts`):
* safe to import from anything that only needs the constant strings — a
* dashboard, a CLI, an alert rule — without pulling in the OpenTelemetry SDK.
*
* These keys are a public API for the agents that query your telemetry. Treat a
* rename here the way you'd treat a breaking change to any other contract.
*/
declare const VALIDATION_ATTR: {
/** Contract id of the validated boundary, e.g. `POST /orders`, `order.placed`. */
readonly name: "validation.name";
/** Where validation ran: `http` | `event` | `message` | a custom label. */
readonly boundary: "validation.boundary";
/** `observe` (recorded, request continues) or `reject` (recorded, then failed). */
readonly mode: "validation.mode";
/** Stable hash of the declared shape, when a JSON-schema projection is given. */
readonly hash: "validation.hash";
/** `info` | `warning` | `error`. */
readonly severity: "validation.severity";
/** Number of failing fields. */
readonly issueCount: "validation.issue.count";
/** Comma-separated failing field paths (capped). Never contains values. */
readonly issuePaths: "validation.issue.paths";
/** Comma-separated distinct issue codes (capped). Never contains values. */
readonly issueCodes: "validation.issue.codes";
};
type ValidationAttributeKey = (typeof VALIDATION_ATTR)[keyof typeof VALIDATION_ATTR];
declare const VALIDATION_METRICS: {
/** Counter, labelled `{ boundary, validation, mode }`. */
readonly mismatches: "autotel.validation.mismatches";
};
/** Max field paths / codes stamped onto a span, to bound attribute size. */
declare const VALIDATION_ISSUE_CAP = 20;
export { VALIDATION_ATTR, VALIDATION_ISSUE_CAP, VALIDATION_METRICS, type ValidationAttributeKey };