assignMetrics
constassignMetrics: (config?) =>Policy
Defined in: src/policies/observability/assign-metrics.ts:43
Attach metric tags to the request context for downstream consumers.
Tags are resolved (static or dynamic) and stored as a plain object at
c.get("_metricsTags"). The metricsReporter policy (or any custom
observer) can read these tags to enrich collected metrics.
Parameters
Section titled “Parameters”config?
Section titled “config?”Must include tags — a record of tag names to values or resolver functions.
Returns
Section titled “Returns”A Policy at priority 0 (OBSERVABILITY).
Example
Section titled “Example”import { assignMetrics } from "@homegrower-club/stoma";
assignMetrics({ tags: { service: "users-api", region: (c) => c.req.header("cf-ipcountry") ?? "unknown", },});