Langfuse โ€” Open-Source Observability

Lesson 6: Langfuse โ€” Open-Source Observability

Langfuse is the open-source challenger on the observe layer: an independent, self-hostable platform for LLM tracing, evaluation, prompt management, and cost tracking. If LangSmith is the Apple of LLMOps (polished, hosted, integrated), Langfuse is the Linux โ€” open-source core, run it on your own hardware, no vendor lock-in. (The Langfuse team is now part of ClickHouse, and v4 shipped in August 2026 with major performance and real-time ingestion upgrades.)

Key idea: Langfuse covers almost the same feature set as LangSmith โ€” traces, evals, datasets, prompt versioning, sessions, feedback โ€” but its open-source license (Apache 2.0) and self-hosting story are the deciding factors for teams that can't (or won't) send prompts and outputs to a third-party SaaS.
Langfuse v4 (August 2026): the big 2026 release is built on OpenTelemetry to reduce lock-in, claims up to 165ร— faster at scale, and adds real-time ingestion (data appears instantly instead of waiting on batch jobs). Built on Postgres + ClickHouse for storage and analytics.

What Langfuse gives you

FeatureWhat it does
TracingFull run traces with token usage, latency, and cost per model call
SessionsGroup traces by user or conversation for end-to-end analysis
Prompt managementVersioned prompts with labels (production/staging), deployable from the UI
Evals & datasetsLLM-as-judge, custom scoring functions, and curated test sets
Cost trackingPer-project, per-model spend analytics
Feedback & guardrailsUser thumbs-up/down, annotation queues, moderation checks
ExperimentsA/B-ish comparison of prompts/models against datasets

Deployment options

  • Langfuse Cloud โ€” hosted SaaS with a free tier; zero ops.
  • Self-hosted (Docker) โ€” the popular choice: docker compose up gets a full stack (app + Postgres + ClickHouse for analytics) running locally.
  • Enterprise / Kubernetes โ€” for large-scale self-hosting with SSO and RBAC.
# Self-host with Docker
git clone https://github.com/langfuse/langfuse.git
cd langfuse
cp .env.example .env   # set secrets, then:
docker compose up -d

Hooking it up

Langfuse integrates with LangChain through a callback handler โ€” again, near-zero code changes:

from langfuse.callback import CallbackHandler

langfuse_handler = CallbackHandler(
    public_key="pk-...", secret_key="sk-...",
    host="http://localhost:3000"   # or https://cloud.langfuse.com
)

result = chain.invoke({"topic": "RAG"}, config={"callbacks": [langfuse_handler]})

Beyond LangChain, Langfuse supports plain OpenAI/Anthropic SDKs, its own Python/JS SDKs, and โ€” importantly โ€” the OpenTelemetry GenAI semantic conventions, meaning any OTel-instrumented app can send traces to it. This is the same OTel story LangSmith adopted, and it's what makes the observe layer genuinely swappable.

SELF-HOSTED STACK Langfuse app (Next.js) PostgreSQL ClickHouse (analytics) docker compose up โ€” all three behind one command
Pitfall: Self-hosting is a real operational commitment โ€” Postgres + ClickHouse need backups, upgrades, and monitoring. For a hobby project or early prototype, Langfuse Cloud's free tier is often the right call; move to self-hosted when data governance demands it.
Rule of thumb: Pick Langfuse when you want open source, self-hosting, or cost control. Pick LangSmith when you want the tightest LangChain integration and managed SaaS simplicity. Both are fine; the lock-in is in the data, not the code โ€” traces are swappable if you standardize early.

๐Ÿง  Knowledge Check

1. What's the headline difference between Langfuse and LangSmith?

2. How do you integrate Langfuse with a LangChain app?

3. What standard makes observability platforms swappable?

Further Reading