Skip to content

The only tool you need to know what is happening and how to fix it.

419 B
Raw Blame
import { withRoute } from "@/lib/with-route";
import { trace } from "@opentelemetry/api";

const tracer = trace.getTracer("nextjs-otel-example");

export const GET = withRoute("/nextjs/api/slow", async () => {
  await tracer.startActiveSpan("slow-operation", async (span) => {
    await new Promise((resolve) => setTimeout(resolve, 300));
    span.end();
  });
  return Response.json({ message: "Slow response" });
});