| name | langfuse-multi-env-setup |
| description | Configure Langfuse across development, staging, and production environments.
Use when setting up multi-environment deployments, configuring per-environment keys,
or implementing environment-specific Langfuse configurations.
Trigger with phrases like "langfuse environments", "langfuse staging",
"langfuse dev prod", "langfuse environment setup", "langfuse config by env".
|
| allowed-tools | Read, Write, Edit, Bash(aws:*), Bash(gcloud:*), Bash(vault:*) |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","langfuse","deployment"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Langfuse Multi-Environment Setup
Overview
Configure Langfuse across dev/staging/production with isolated API keys, environment-specific SDK settings, secret management, and CI/CD integration to prevent cross-environment data leakage.
Prerequisites
- Separate Langfuse API key pairs per environment (or separate projects)
- Secret management solution (env vars, Vault, AWS/GCP secrets)
- CI/CD pipeline with environment-aware deployment
Environment Strategy
| Environment | API Key Source | Langfuse Project | Settings |
|---|
| Development | .env.local | Dev project | Debug on, flush immediately, 100% sampling |
| Staging | CI/CD secrets | Staging project | Prod-like settings, 50% sampling |
| Production | Secret manager | Prod project | Optimized batching, 10% sampling |
Instructions
Step 1: Environment-Specific Configuration
import { LangfuseSpanProcessor } from "@langfuse/otel";
import { NodeSDK } from "@opentelemetry/sdk-node";
import { LangfuseClient } from "@langfuse/client";
type Env = "development" | "staging" | "production";
interface LangfuseEnvConfig {
exportIntervalMillis: number;
maxExportBatchSize: number;
debug: boolean;
sampleRate: ;
}
: <, > = {
: {
: ,
: ,
: ,
: ,
},
: {
: ,
: ,
: ,
: ,
},
: {
: ,
: ,
: ,
: ,
},
};
(): {
env = process.. || ;
(env === ) ;
(env === || process.. === ) ;
;
}
() {
env = ();
config = [env];
required = [, ];
( key required) {
(!process.[key]) {
();
}
}
processor = ({
: config.,
: config.,
});
sdk = ({ : [processor] });
sdk.();
client = ();
.();
{ sdk, client, env, config };
}