-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
30 lines (23 loc) · 915 Bytes
/
Copy pathinstrumentation.ts
File metadata and controls
30 lines (23 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import * as Sentry from "@sentry/nextjs";
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("./sentry.server.config");
// Langfuse AI observability via OpenTelemetry
const { LangfuseSpanProcessor } = await import("@langfuse/otel");
const { NodeTracerProvider } = await import("@opentelemetry/sdk-trace-node");
const langfuseSpanProcessor = new LangfuseSpanProcessor({
// Only export AI SDK spans, not Next.js infra spans
shouldExportSpan: (span) => {
return span.otelSpan.instrumentationScope.name !== "next.js";
},
});
const tracerProvider = new NodeTracerProvider({
spanProcessors: [langfuseSpanProcessor],
});
tracerProvider.register();
}
if (process.env.NEXT_RUNTIME === "edge") {
await import("./sentry.edge.config");
}
}
export const onRequestError = Sentry.captureRequestError;