You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

23 lines
665 B

/**
* Langfuse + OpenTelemetry instrumentation for AI agent observability.
* Must be imported before any other modules to ensure all spans are captured.
*/
import { NodeSDK } from "@opentelemetry/sdk-node";
import { LangfuseSpanProcessor } from "@langfuse/otel";
const langfuseEnabled =
!!process.env.LANGFUSE_SECRET_KEY && !!process.env.LANGFUSE_PUBLIC_KEY;
if (langfuseEnabled) {
const sdk = new NodeSDK({
spanProcessors: [new LangfuseSpanProcessor()]
});
sdk.start();
console.log("[Langfuse] OpenTelemetry tracing initialized");
} else {
console.log(
"[Langfuse] Skipped — LANGFUSE_SECRET_KEY and LANGFUSE_PUBLIC_KEY not set"
);
}