feat: the trust release — observability, shutdown teardown, routing correctness and the docs split #41
+5
-1
@@ -27,6 +27,11 @@ export interface NeutralRequest {
|
||||
traceId?: string;
|
||||
}
|
||||
|
||||
// Module scope, not a local inside `correlateRequest`. Declared there it was a closure allocated
|
||||
// on every single request, which measured at 0.16 us against a ~4.4 us one — 45% of the whole
|
||||
// observability overhead, for a helper that captures nothing.
|
||||
const first = (value: string | string[] | undefined): string | undefined => (Array.isArray(value) ? value[0] : value);
|
||||
|
||||
/**
|
||||
* Derives a request's identity from its headers, for the adapters to stamp on a `NeutralRequest`.
|
||||
*
|
||||
@@ -43,7 +48,6 @@ export function correlateRequest(headers: Record<string, string | string[] | und
|
||||
requestId: string;
|
||||
traceId?: string;
|
||||
} {
|
||||
const first = (value: string | string[] | undefined): string | undefined => (Array.isArray(value) ? value[0] : value);
|
||||
const incoming = first(headers['x-request-id'])?.trim();
|
||||
const traceId = first(headers.traceparent)?.trim();
|
||||
|
||||
|
||||
Reference in new issue
Block a user