Langfuse Production Checklist
Overview
Comprehensive checklist for deploying Langfuse observability to production with verified configuration, error handling, graceful shutdown, monitoring, and a pre-deployment verification script.
Prerequisites
- Development and staging testing completed
- Production Langfuse project created with separate API keys
- Secret management solution in place
Production Configuration
Recommended SDK Settings
import { LangfuseSpanProcessor } from "@langfuse/otel";
import { NodeSDK } from "@opentelemetry/sdk-node";
const processor = new LangfuseSpanProcessor({
exportIntervalMillis: 5000,
maxExportBatchSize: 50,
maxQueueSize: 2048,
});
const sdk = new NodeSDK({ spanProcessors: [processor] });
sdk.start();
for (const signal of ["SIGTERM", "SIGINT", "SIGUSR2"]) {
process.on(signal, async () => {
await sdk.shutdown();
process.exit(0);
});
}
import { Langfuse } from "langfuse";
const langfuse = new Langfuse({
flushAt: 25,
flushInterval: 5000,
requestTimeout: 15000,
enabled: true,
});
process.on("beforeExit", () => langfuse.shutdownAsync());
process.on("SIGTERM", () => langfuse.shutdownAsync().then(() => process.exit(0)));
Production Error Handling
import { observe, updateActiveObservation, startActiveObservation } from "@langfuse/tracing";
const tracedEndpoint = observe({ name: "api-endpoint" }, async (req: Request) => {
try {
updateActiveObservation({
input: { path: req.url, method: req.method },
metadata: { userId: req.userId },
});
const result = await processRequest(req);
updateActiveObservation({ output: { status: 200 } });
return result;
} catch (error) {
try {
updateActiveObservation({
output: { error: String(error) },
metadata: { level: "ERROR" },
});
} catch {
}
throw error;
}
});
Pre-Deployment Verification Script
import { LangfuseClient } from "@langfuse/client";
import { startActiveObservation, updateActiveObservation } from "@langfuse/tracing";
async function verify() {
const checks: Array<{ name: string; pass: boolean; detail: string }> = [];
const requiredVars = ["LANGFUSE_PUBLIC_KEY", "LANGFUSE_SECRET_KEY"];
for (const v of requiredVars) {
checks.push({
name: `Env: ${v}`,
pass: !!process.env[v],
detail: process.env[v] ? `SET (${process.env[v]!.slice(0, 10)}...)` : "MISSING",
});
}
const pk = process.env.LANGFUSE_PUBLIC_KEY || "";
const sk = process.env.LANGFUSE_SECRET_KEY || "";
checks.push({
: ,
: pk.() && sk.(),
: ,
});
{
langfuse = ();
langfuse..().( {});
checks.({ : , : , : });
} (error) {
checks.({ : , : , : (error) });
}
{
(, () => {
({
: { : },
: { : },
: { : },
});
});
checks.({ : , : , : });
} (error) {
checks.({ : , : , : (error) });
}
.();
allPassed = ;
( check checks) {
icon = check. ? : ;
.();
(!check.) allPassed = ;
}
.();
(!allPassed) process.();
}
();
Production Checklist
Authentication & Security
SDK Configuration
Reliability
Monitoring
Operations
Error Handling
| Issue | Cause | Solution |
|---|
| Missing traces in prod | No flush on exit | Add shutdown handler for SIGTERM |
| Memory growth | Client created per request | Use singleton pattern |
| High latency | Small batches | Increase flushAt to 25-50 |
| Lost traces on deploy | No graceful shutdown | Add SIGTERM handler with sdk.shutdown() |
Resources