Create Express middleware for automatic trace flushing
Flushes traces when the response finishes (after res.send/res.json). This is fire-and-forget and doesn't block the response.
Express middleware function
// Global middlewareapp.use(createMiddleware()); Copy
// Global middlewareapp.use(createMiddleware());
// Per-route middlewareapp.post('/chat', createMiddleware(), async (req, res) => { res.json({ ok: true });}); Copy
// Per-route middlewareapp.post('/chat', createMiddleware(), async (req, res) => { res.json({ ok: true });});
Create Express middleware for automatic trace flushing
Flushes traces when the response finishes (after res.send/res.json). This is fire-and-forget and doesn't block the response.