fix(logging): carry the route template in http.route

http.route held the concrete pathname, so every record id minted a route of
its own and grouping by route answered nothing. apiHandler recovers the
template from the handler's params and puts it there; http.path keeps the
concrete path, and path-secret redaction still runs on both.
This commit is contained in:
Marc-André Bombeck committed 2026-10-20 05:57:20 +02:00
1 parent fbbb535832
commit 72214c0208
3 files changed
+207 -1

No files matched your search

+4 -1
View File
@@ -11,6 +11,7 @@ import { WideEventBuilder } from "./logging/event-builder";
import { annotate, eventStorage, getEvent } from "./logging/context";
import { emitIfSampled } from "./logging/transports";
import { redactOptional, redactSecrets } from "./logging/redact";
import { routeTemplateFor } from "./logging/route-template";
import { getSession } from "./auth/session";
import {
hasSecondFactorEnrolled,
@@ -241,7 +242,9 @@ export function apiHandler<T extends (...args: any[]) => Promise<Response>>(
evt.setHttp({
method: safeRequestProp(request, (r) => r.method, "GET"),
path: url.pathname,
route: url.pathname,
// The handler's template (`/api/medications/[id]`), not the concrete
// path: one route per handler, so dashboards can group on it.
route: await routeTemplateFor(url.pathname, args[1]),
status: 200,
user_agent:
safeRequestProp(request, (r) => r.headers.get("user-agent"), null) ??