Kernel middleware that records one span (and a counter) per processed event.
It stays platform-agnostic: it spans every IncomingEvent with its type, reads a
statusCode off the response only when present, and derives the outcome using the
OpenTelemetry convention (thrown error, or status >= 500 → error; otherwise ok). This
matters because the kernel turns handler errors into responses rather than re-throwing, so a
failed request surfaces as a 5xx response — not an exception — at the middleware boundary.
Errors that are thrown are recorded and re-thrown; telemetry never swallows them.
Kernel middleware that records one span (and a counter) per processed event.
It stays platform-agnostic: it spans every
IncomingEventwith itstype, reads astatusCodeoff the response only when present, and derives the outcome using the OpenTelemetry convention (thrown error, or status >= 500 →error; otherwiseok). This matters because the kernel turns handler errors into responses rather than re-throwing, so a failed request surfaces as a 5xx response — not an exception — at the middleware boundary. Errors that are thrown are recorded and re-thrown; telemetry never swallows them.