Skip to content
Stacklumen is now a solutions companySee the list here

Express can now be traced without patching it

Express's router 2.3.0 publishes a Node.js tracing channel for every middleware and route handler, so logs, metrics and traces no longer need Express to be wrapped. Here is what it sends and what to check on your own app.

Stacklumen blog card reading 'Express can now be traced without patching it.' beside a code window that subscribes to the express.router.request tracing channel, and an events list for one GET /orders/:id request showing two start events and an error event from a loadOrder handler.
On this page
  1. What changed
  2. What each event tells you
  3. Why this is different from before
  4. Other changes in router 2.3.0
  5. What it means for your site
  6. Sources

Express apps can now be observed without wrapping or patching Express itself. On 17 November 2026 the Express project announced that its router publishes a Node.js tracing channel for every middleware, route handler and router.param() callback. Loggers, monitoring tools and your own code can subscribe to it and turn the events into logs, metrics or traces.

What changed

The change ships in version 2.3.0 of router, the package that handles routing in Express 5. The router now publishes to Node.js's diagnostics_channel module through a TracingChannel named express.router.request.

You do not need a new version of Express. The Express post says every Express 5 app already depends on router, so your lockfile only has to pick up 2.3.0. The events need Node.js 18.19 or later. Tracing channels arrived in Node.js 19.9 and were backported to 18.19, and on older versions nothing is published. The Node.js documentation marks the tracing channel API as stable from Node.js 26.8.0.

What each event tells you

A tracing channel has five parts that follow one call through its life: start, end, asyncStart, asyncEnd and error. With each event the router passes a context object. According to the Express post, it holds:

  • req and res, the request and response.
  • route, the matched path pattern, such as /users/:id rather than /users/42.
  • handler, the middleware, route handler or param callback being run.
  • param, the parameter name, for router.param() callbacks only.
  • error, the error a handler reported by calling next(err), throwing or rejecting.
  • incomingError and errorHandler, which describe error-handling middleware.
  • result, what the handler returned or what its promise resolved to.

To listen, you load node:diagnostics_channel, call tracingChannel('express.router.request') and pass subscribe() an object with a function for each event you care about. The post's own example logs the method, the route pattern and the handler's name on start, and logs the handler's name and the error on error.

Why this is different from before

The Express post sets out the problems with the usual ways of instrumenting Express. Monitoring tools have often wrapped methods such as app.use and app.get, which can break handler signatures. A wrapper that accepts only three arguments, for example, breaks error handlers that take four. Module hooks require the instrumentation to load before Express and fail when a bundler inlines express.

A tracing channel avoids both. It uses AsyncLocalStorage to match the start and end of each call, so events from requests that run at the same time do not get mixed up. The post says publishing to a channel with no subscribers is close to free, so apps that do not listen pay almost nothing for it.

The post also shows uses it expects to be common: timing each route by its pattern, so /users/1 and /users/2 land in one bucket; logging which middleware failed; and creating a child span per handler with OpenTelemetry, nested under the request span that OpenTelemetry's HTTP instrumentation already creates.

Other changes in router 2.3.0

The release notes list two more additions. A new router.listRoutes() method returns the registered routes without reading the router's internal stack. Router and Route now ship with their own TypeScript type declarations. Smaller fixes include malformed route parameters now setting err.statusCode to 400.

What it means for your site

  • If your site or API runs on Express 5, check which version of router your lockfile resolves. Updating your lockfile so it picks up 2.3.0 is all the Express post asks for. Test before you deploy, since the release also changes how malformed parameters are reported.
  • Check your Node.js version. You need 18.19 or later for the events to be published.
  • If you use a monitoring tool, check its documentation for support of the express.router.request channel before removing any existing Express instrumentation.
  • Group timings and errors by the route pattern, not the full URL, so reports stay readable.
  • The req object is passed to subscribers. Avoid logging headers, cookies or request bodies, which can hold personal data or credentials.

Sources

New posts by email

Product updates and field notes from Stacklumen, in one email a day or one a week.

How often