Your route handler function
Optionaloptions: NextObserveOptionsOptional: pass after (Next.js 15+) or waitUntil (Vercel)
Wrapped handler that auto-flushes traces
// Basic usage (blocking flush)
export const POST = withObserve(async (req) => {
return Response.json({ ok: true });
});
Wrap a Next.js App Router handler with automatic trace flushing