Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Execute complex Langfuse migrations including data migration and platform changes. Use when migrating from other observability platforms, moving between Langfuse instances, or performing major infrastructure migrations. Trigger with phrases like "langfuse migration", "migrate to langfuse", "langfuse data migration", "langfuse platform migration", "switch to langfuse".
.claude/skills/jeremylongshore-langfuse-migration-deep-dive/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 56% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 25% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 136% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 66% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 113% | 0% |
!npm list langfuse @langfuse/client 2>/dev/null | head -5 || echo 'No langfuse packages'
Comprehensive guide for complex migrations: cloud-to-self-hosted, LangSmith-to-Langfuse, cross-instance data migration, and zero-downtime dual-write patterns.
| Scenario | Complexity | Downtime | Data Loss Risk | |----------|-----------|----------|----------------| | Cloud to Cloud (different project) | Low | None | None | | Cloud to Self-hosted | Medium | Minutes | Low | | Self-hosted to Cloud | Medium | Minutes | Low | | LangSmith to Langfuse | High | Hours | Medium | | SDK v3 to v4+ (no data migration) | Low | None | None |
typescript// scripts/export-langfuse.ts import { LangfuseClient } from "@langfuse/client"; import { writeFileSync, mkdirSync } from "fs"; const source = new LangfuseClient({ publicKey: process.env.SOURCE_LANGFUSE_PUBLIC_KEY, secretKey: process.env.SOURCE_LANGFUSE_SECRET_KEY, baseUrl: process.env.SOURCE_LANGFUSE_BASE_URL, }); async function exportAll(outputDir: string) { mkdirSync(outputDir, { recursive: true }); // Export traces let page = 1; let allTraces: any[] = []; let hasMore = true; console.log("Exporting traces..."); while (hasMore) { const result = await source.api.traces.list({ limit: 100, page }); allTraces.push(...result.data); hasMore = result.data.length === 100; page++; await new Promise((r) => setTimeout(r, 200)); // Rate limit } writeFileSync(`${outputDir}/traces.json`, JSON.stringify(allTraces, null, 2)); console.log(` Exported ${allTraces.length} traces`); // Export scores page = 1; let allScores: any[] = []; hasMore = true; console.log("Exporting scores..."); while (hasMore) { const result = await source.api.scores.list({ limit: 100, page }); allScores.push(...result.data); hasMore = result.data.length === 100; page++; await new Promise((r) => setTimeout(r, 200)); } writeFileSync(`${outputDir}/scores.json`, JSON.stringify(allScores, null, 2)); console.log(` Exported ${allScores.length} scores`); // Export prompts console.log("Exporting prompts..."); const prompts = await source.api.prompts.list({ limit: 100 }); writeFileSync(`${outputDir}/prompts.json`, JSON.stringify(prompts.data, null, 2)); console.log(` Exported ${prompts.data.length} prompts`); // Export datasets console.log("Exporting datasets..."); const datasets = await source.api.datasets.list({ limit: 100 }); const fullDatasets = []; for (const ds of datasets.data) { const items = await source.api.datasetItems.list({ datasetName: ds.name, limit: 1000 }); fullDatasets.push({ ...ds, items: items.data }); await new Promise((r) => setTimeout(r, 200)); } writeFileSync(`${outputDir}/datasets.json`, JSON.stringify(fullDatasets, null, 2)); console.log(` Exported ${fullDatasets.length} datasets`); } exportAll("./migration-export");
typescript// scripts/import-langfuse.ts import { LangfuseClient } from "@langfuse/client"; import { readFileSync } from "fs"; const target = new LangfuseClient({ publicKey: process.env.TARGET_LANGFUSE_PUBLIC_KEY, secretKey: process.env.TARGET_LANGFUSE_SECRET_KEY, baseUrl: process.env.TARGET_LANGFUSE_BASE_URL, }); async function importAll(inputDir: string) { // Import prompts first (no dependencies) console.log("Importing prompts..."); const prompts = JSON.parse(readFileSync(`${inputDir}/prompts.json`, "utf-8")); for (const prompt of prompts) { await target.api.prompts.create({ name: prompt.name, prompt: prompt.prompt, type: prompt.type, config: prompt.config, labels: prompt.labels, }); console.log(` Imported prompt: ${prompt.name}`); await new Promise((r) => setTimeout(r, 100)); } // Import datasets console.log("Importing datasets..."); const datasets = JSON.parse(readFileSync(`${inputDir}/datasets.json`, "utf-8")); for (const ds of datasets) { await target.api.datasets.create({ name: ds.name, description: ds.description, metadata: { ...ds.metadata, migratedFrom: "source-instance" }, }); for (const item of ds.items || []) { await target.api.datasetItems.create({ datasetName: ds.name, input: item.input, expectedOutput: item.expectedOutput, metadata: item.metadata, }); await new Promise((r) => setTimeout(r, 50)); } console.log(` Imported dataset: ${ds.name} (${ds.items?.length || 0} items)`); } console.log("Import complete."); console.log("Note: Traces and scores are historical -- they reference old trace IDs."); console.log("New traces will be created by your application pointing to the target."); } importAll("./migration-export");
Write traces to both instances during transition:
typescript// src/lib/dual-write-langfuse.ts import { LangfuseSpanProcessor } from "@langfuse/otel"; import { NodeSDK } from "@opentelemetry/sdk-node"; // Create processors for both instances const sourceProcessor = new LangfuseSpanProcessor({ publicKey: process.env.SOURCE_LANGFUSE_PUBLIC_KEY, secretKey: process.env.SOURCE_LANGFUSE_SECRET_KEY, baseUrl: process.env.SOURCE_LANGFUSE_BASE_URL, }); const targetProcessor = new LangfuseSpanProcessor({ publicKey: process.env.TARGET_LANGFUSE_PUBLIC_KEY, secretKey: process.env.TARGET_LANGFUSE_SECRET_KEY, baseUrl: process.env.TARGET_LANGFUSE_BASE_URL, }); // Both processors receive all spans const sdk = new NodeSDK({ spanProcessors: [sourceProcessor, targetProcessor], }); sdk.start(); // Migration timeline: // Week 1: Dual-write enabled, verify target receives traces // Week 2: Validate data parity between instances // Week 3: Switch primary to target, keep source as backup // Week 4: Remove source processor
typescript// scripts/validate-migration.ts import { LangfuseClient } from "@langfuse/client"; const source = new LangfuseClient({ publicKey: process.env.SOURCE_LANGFUSE_PUBLIC_KEY, secretKey: process.env.SOURCE_LANGFUSE_SECRET_KEY, baseUrl: process.env.SOURCE_LANGFUSE_BASE_URL, }); const target = new LangfuseClient({ publicKey: process.env.TARGET_LANGFUSE_PUBLIC_KEY, secretKey: process.env.TARGET_LANGFUSE_SECRET_KEY, baseUrl: process.env.TARGET_LANGFUSE_BASE_URL, }); async function validate() { // Compare prompt counts const sourcePrompts = await source.api.prompts.list({ limit: 100 }); const targetPrompts = await target.api.prompts.list({ limit: 100 }); console.log(`Prompts: source=${sourcePrompts.data.length}, target=${targetPrompts.data.length}`); // Compare dataset counts const sourceDatasets = await source.api.datasets.list({ limit: 100 }); const targetDatasets = await target.api.datasets.list({ limit: 100 }); console.log(`Datasets: source=${sourceDatasets.data.length}, target=${targetDatasets.data.length}`); // Compare recent trace counts (dual-write period) const since = new Date(Date.now() - 3600000).toISOString(); const sourceTraces = await source.api.traces.list({ fromTimestamp: since, limit: 100 }); const targetTraces = await target.api.traces.list({ fromTimestamp: since, limit: 100 }); console.log(`Recent traces (1h): source=${sourceTraces.data.length}, target=${targetTraces.data.length}`); const variance = Math.abs(sourceTraces.data.length - targetTraces.data.length) / Math.max(sourceTraces.data.length, 1); console.log(`Trace variance: ${(variance * 100).toFixed(1)}% (target: <5%)`); } validate();
typescript// After validation passes: // 1. Update environment variables to point to target // LANGFUSE_PUBLIC_KEY=pk-lf-target-... // LANGFUSE_SECRET_KEY=sk-lf-target-... // LANGFUSE_BASE_URL=https://target.langfuse.com // 2. Remove dual-write (use single processor) const sdk = new NodeSDK({ spanProcessors: [targetProcessor], // Only target }); // 3. Keep source instance running for 30 days (rollback window) // 4. After 30 days, decommission source
bashset -euo pipefail # If migration fails, switch back to source: # 1. Update environment variables export LANGFUSE_PUBLIC_KEY="pk-lf-source-..." export LANGFUSE_SECRET_KEY="sk-lf-source-..." export LANGFUSE_BASE_URL="https://source.langfuse.com" # 2. Restart application # 3. Verify traces flowing to source
| Issue | Cause | Solution | |-------|-------|----------| | Export timeout | Too much data | Paginate with smaller page sizes | | Import duplicates | Re-running import | Use idempotent creates with unique names | | Dual-write divergence | One instance failing | Monitor both, alert on variance > 5% | | Missing prompts | Not exported | Export prompts before datasets |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 44,181 | 39,016 | -12% | 1 | 1 | 0% | 5,188 | 8,103 | +56% | 0 | 0 | — |
case-02 | fail→pass | 30,941 | 25,274 | -18% | 1 | 1 | 0% | 5,477 | 6,871 | +25% | 0 | 0 | — |
case-03 | fail→fail | 42,726 | 36,181 | -15% | 1 | 1 | 0% | 8,239 | 9,390 | +14% | 0 | 0 | — |
case-04 | pass→pass | 21,819 | 20,261 | -7% | 1 | 1 | 0% | 3,001 | 5,625 | +87% | 0 | 0 | — |
case-05 | fail→pass | 18,924 | 15,414 | -19% | 1 | 1 | 0% | 2,083 | 4,916 | +136% | 0 | 0 | — |
case-06 | fail→pass | 22,499 | 23,032 | +2% | 1 | 1 | 0% | 3,383 | 5,632 | +66% | 0 | 0 | — |
case-07 | pass→pass | 12,285 | 12,849 | +5% | 1 | 1 | 0% | 2,065 | 5,216 | +153% | 0 | 0 | — |
case-08 | pass→pass | 26,341 | 21,888 | -17% | 1 | 1 | 0% | 2,876 | 6,855 | +138% | 0 | 0 | — |
case-09 | pass→pass | 24,920 | 13,266 | -47% | 1 | 1 | 0% | 2,847 | 4,302 | +51% | 0 | 0 | — |
case-10 | fail→pass | 12,201 | 8,830 | -28% | 1 | 1 | 0% | 1,823 | 3,887 | +113% | 0 | 0 | — |
case-11 | pass→fail | 15,667 | 21,126 | +35% | 1 | 1 | 0% | 2,494 | 5,047 | +102% | 0 | 0 | — |
case-12 | pass→pass | 24,077 | 20,338 | -16% | 1 | 1 | 0% | 2,782 | 5,839 | +110% | 0 | 0 | — |
case-13 | pass→pass | 17,727 | 19,820 | +12% | 1 | 1 | 0% | 2,412 | 5,487 | +127% | 0 | 0 | — |
case-14 | pass→pass | 9,041 | 17,802 | +97% | 1 | 1 | 0% | 1,347 | 4,715 | +250% | 0 | 0 | — |
case-15 | fail→pass | 37,580 | 5,862 | -84% | 1 | 1 | 0% | 1,303 | 3,661 | +181% | 0 | 0 | — |
case-16 | fail→fail | 21,164 | 11,720 | -45% | 1 | 1 | 0% | 2,414 | 4,781 | +98% | 0 | 0 | — |
case-17 | fail→pass | 24,686 | 2,668 | -89% | 1 | 1 | 0% | 1,072 | 3,268 | +205% | 0 | 0 | — |
case-18 | fail→pass | 8,865 | 8,351 | -6% | 1 | 1 | 0% | 1,336 | 3,396 | +154% | 0 | 0 | — |
case-19 | fail→fail | 25,264 | 22,078 | -13% | 1 | 1 | 0% | 3,158 | 5,220 | +65% | 0 | 0 | — |
case-20 | pass→pass | 17,402 | 17,066 | -2% | 1 | 1 | 0% | 2,083 | 4,944 | +137% | 0 | 0 | — |
case-21 | fail→pass | 21,709 | 23,586 | +9% | 1 | 1 | 0% | 2,375 | 5,675 | +139% | 0 | 0 | — |
case-22 | pass→pass | 18,187 | 17,969 | -1% | 1 | 1 | 0% | 2,336 | 5,010 | +114% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 20 counted toward the lift figure. The other 2 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +36 percentage points is the difference between those two pass rates over the 20 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.