From 87cdc53665f6a92d5910f17b44122dc9aec28084 Mon Sep 17 00:00:00 2001 From: Dayuan Jiang <34411969+DayuanJiang@users.noreply.github.com> Date: Tue, 23 Dec 2025 09:47:23 +0900 Subject: [PATCH] fix: improve Langfuse span filter to exclude all Next.js infrastructure traces (#365) * debug: add log to verify instrumentation initialization * fix: improve Langfuse span filter to exclude all Next.js infrastructure traces --- instrumentation.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/instrumentation.ts b/instrumentation.ts index abd8c14..7fe59fb 100644 --- a/instrumentation.ts +++ b/instrumentation.ts @@ -19,10 +19,13 @@ export function register() { const spanName = otelSpan.name // Skip Next.js HTTP infrastructure spans if ( - spanName.startsWith("POST /") || - spanName.startsWith("GET /") || + spanName.startsWith("POST") || + spanName.startsWith("GET") || + spanName.startsWith("RSC") || spanName.includes("BaseServer") || - spanName.includes("handleRequest") + spanName.includes("handleRequest") || + spanName.includes("resolve page") || + spanName.includes("start response") ) { return false } @@ -36,4 +39,5 @@ export function register() { // Register globally so AI SDK's telemetry also uses this processor tracerProvider.register() + console.log("[Langfuse] Instrumentation initialized successfully") }