Migrate from Langfuse
Use this skill to move an AI application's tracing from Langfuse to
Confident AI. The target is the confident-trace SDK: init() for
automatic instrumentation, span for your own steps, and update_trace() /
update_span() for trace and span fields.
What changes depends on the Langfuse SDK version in the app, not the Langfuse server version. Each version has its own reference file.
Workflow
-
Find every Langfuse integration. Search for imports of
langfuseand@langfuse/*,Langfuse()andnew Langfuse(),@observeandobserve(),langfuse_context,get_client(),langfuse.trace(),trace.span(),trace.generation(),start_as_current_span(),start_as_current_observation(),startActiveObservation(),langfuse.openai,observeOpenAI,LangfuseMedia,LangfuseSpanProcessor, the LangfuseCallbackHandler, andLANGFUSE_*environment variables or keys passed in code. -
Confirm the installed SDK version. Run
pip show langfuse,npm ls langfuse, ornpm ls @langfuse/tracing. Python and TypeScript services in one repo can be on different versions, so check each one. -
Read the reference for that version.
Installed SDK Reference Python langfuse<2, TypeScriptlangfuse@1references/langfuse-v1.mdPython langfuse>=2,<3, TypeScriptlangfuse@2references/langfuse-v2.mdPython langfuse>=3,<4, TypeScriptlangfuse@3references/langfuse-v3.mdPython langfuse>=4, TypeScript@langfuse/tracingv4 or v5references/langfuse-v4.mdThere is no need to upgrade Langfuse first. Every version moves straight to confident-trace.
-
Pick the method. Default to the full switch: replace the Langfuse SDK with confident-trace. Use the OpenTelemetry method only when the user asks to keep Langfuse instrumentation in place, and only where the reference says it is available. Tell the user its limits before you start.
-
Make the changes in the order the reference gives. Read
references/common.mdfor the install, endpoint, LangChain, media, and flush rules that apply to every version. -
Preserve behavior. Keep the same span names, nesting, inputs, outputs, users, sessions, tags, and metadata. A Langfuse session ID becomes a confident-trace thread ID.
-
Leave prompt, dataset, and score calls alone. Calls such as
get_prompt(),create_dataset(),create_dataset_item(), andscore()use the Langfuse API, not tracing. Do not delete or rewrite them. List them for the user. If any remain, keep thelangfusepackage installed and remove only the tracing code. -
Verify. Run the app once and confirm the trace appears in the project's Observatory. If it does not, check that
CONFIDENT_API_KEYis set in the same process and that the app flushes before it exits. -
Report. Summarize every change. List what still needs the user: setting
CONFIDENT_API_KEY, the EU or self-hosted endpoint, model calls you could not map, and the prompt, dataset, and score calls you left in place. Confident AI can import Langfuse datasets, prompts, and historical scores on a migration call.
Core Principles
- Match the reference to the installed SDK version. Stop and ask if the version is unclear or outside v1 to v4.
- Let
init()replace provider wrappers and generations around covered model calls. Do not wrap a call that automatic instrumentation already records. - Keep an LLM span (
span(type="llm")withupdate_span()) only for model calls that automatic instrumentation does not cover. - Never trace secrets or credentials. Carry over any masking the app did through Langfuse.
- For instrumentation beyond a one-to-one migration, such as a framework
integration the app did not use before, use the
confident-tracingskill.
References
| Topic | File |
|---|---|
| Install, endpoints, LangChain, media, and flush rules for every version | references/common.md |
| Langfuse SDK v1 | references/langfuse-v1.md |
| Langfuse SDK v2 | references/langfuse-v2.md |
| Langfuse SDK v3, including the Python OpenTelemetry method | references/langfuse-v3.md |
| Langfuse SDK v4 (TypeScript v4 and v5), including the OpenTelemetry method | references/langfuse-v4.md |
