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