From c3ca92713ed67366bcea163d23991aadfcd41859 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 15:10:53 +0100 Subject: [PATCH] Point the request-wrapper comments at request-tracking.ts --- src/http/app.ts | 2 +- src/logger.ts | 4 ++-- src/server.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/http/app.ts b/src/http/app.ts index f71ebca..c6fd9b4 100644 --- a/src/http/app.ts +++ b/src/http/app.ts @@ -183,7 +183,7 @@ export function createApp(options: AppOptions = {}): Server { { handler: serveDashboard, method: "GET", path: "/dashboard", session: true }, ]; - // The request handler. Run inside runWithLog (below) so the per-request logger is ambient: every + // The request handler. Run inside runWithLog (request-tracking.ts) so the per-request logger is ambient: every // outbound fetch (the Ory clients via tracedFetch) and any deep module joins this request's trace // and correlation with no logger threaded through their signatures. const handleRequest = async (req: IncomingMessage, res: ServerResponse, reqLog: Log): Promise => { diff --git a/src/logger.ts b/src/logger.ts index 8be87dd..bd3b498 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -38,7 +38,7 @@ export function createLogger(opts: LoggerOptions = {}): Log { // The ambient per-request Log (see the header); set by runWithLog, read by currentLog/tracedFetch. const requestStore = new AsyncLocalStorage(); -// Run `fn` with `log` as the ambient request logger (app.ts wraps each request). currentLog() reads +// Run `fn` with `log` as the ambient request logger (request-tracking.ts wraps each request). currentLog() reads // it back; returns undefined outside any request (boot, tests) so callers use `currentLog()?.info(…)`. export function runWithLog(log: Log, fn: () => T): T { return requestStore.run(log, fn); @@ -50,7 +50,7 @@ export function currentLog(): Log | undefined { // A drop-in `fetch` that traces through the active request log — a client span under the request // span, with a W3C `traceparent` injected so the downstream service continues the same trace. // Outside a request, or for a non-string/URL input, it is a plain `fetch`. Note log.fetch throws -// synchronously once the request log has ended; app.ts ends it only after the handler unwinds. +// synchronously once the request log has ended; request-tracking.ts ends it only after the handler unwinds. export const tracedFetch: typeof fetch = (input, init) => { const log = currentLog(); if (log && (typeof input === "string" || input instanceof URL)) return log.fetch(input, init); diff --git a/src/server.ts b/src/server.ts index bb347f4..9e64392 100644 --- a/src/server.ts +++ b/src/server.ts @@ -23,7 +23,7 @@ const config = loadConfig(); // validates the env (incl. enforced secrets) — f // depth, not a boundary (AGENTS.md) — and only ever move this line earlier, never later. delete process.env["PLUGIN_DB_SECRET"]; // App-level logger: structured, OTLP-capable when OTLP_ENDPOINT is set. The hot path clones it -// per request for access logging + a trace span (src/http/app.ts); console-only otherwise. +// per request for access logging + a trace span (src/http/request-tracking.ts); console-only otherwise. const log = createLogger({ format: config.logFormat, level: config.logLevel, otlpEndpoint: config.otlpEndpoint, otlpProtocol: config.otlpProtocol, serviceName: config.serviceName }); const menu = await loadMenuConfig(); // config/menu.ts override + branding — fails loud if malformed // Every outbound Ory call is traced through the active request's logger (a client span continuing