RequestContext
Correlation fields stored in AsyncLocalStorage for the lifetime of a request or job. Every log
line emitted inside the scope is enriched with these. requestId is the only required field; the
rest are populated when headers, trace context, or auth supply them.
Properties
jobId?
optionaljobId?:string
Background job identifier (from x-job-id or set via runWithRequestContext).
requestId
requestId:
string
Stable id shared by all log lines for one request/job; echoed to clients as X-Request-ID.
sessionId?
optionalsessionId?:string
Auth session id, resolved from the JWT/Better Auth session or x-session-id.
spanId?
optionalspanId?:string
Distributed-tracing span id, parsed from Cloud Trace or W3C traceparent.
traceId?
optionaltraceId?:string
Distributed-tracing trace id, parsed from Cloud Trace or W3C traceparent.
traceSampled?
optionaltraceSampled?:boolean
Whether the trace is sampled, per the incoming trace headers.
userId?
optionaluserId?:string
Authenticated user id, populated after auth middleware runs.