Table of Contents

Langfuse

Langfuse is an open-source LLM observability platform that provides tracing, evaluation, prompt management, and cost tracking for production LLM applications. With over 24,000 GitHub stars and MIT licensing, it has become the leading open-source alternative for monitoring and debugging AI applications in production.

Repository github.com/langfuse/langfuse
License MIT
Language TypeScript, Python
Stars 24K+
Category LLM Observability

Key Features

Architecture

Langfuse V4 (March 2026) employs an observations-first, immutable data model aligned with OpenTelemetry spans:

The V4 architecture shifted to an observations-first model where traces are correlation IDs (like session_id) rather than top-level entities, with immutable spans ingested via OTel protocols.

graph TB subgraph Apps["Instrumented Applications"] App1[Python App + SDK] App2[JS/TS App + SDK] App3[OpenTelemetry] App4[LiteLLM Gateway] end subgraph Ingestion["Ingestion Layer"] Queue[Redis + BullMQ] Batch[Micro-Batch Processor] end subgraph Storage["Storage Layer"] PG[(PostgreSQL - Transactional)] CH[(ClickHouse - Traces/Spans)] end subgraph Features["Feature Layer"] Trace[Trace Explorer] Eval[Evaluation Engine] Prompt[Prompt Manager] Cost[Cost Dashboard] Metrics[Metrics and Analytics] end subgraph UI["Web Dashboard"] Dashboard[Dashboard Views] Filters[Saved Filters] Graphs[Agent Graphs] end Apps --> Ingestion Queue --> Batch Batch --> Storage Storage --> Features Features --> UI

Tracing Capabilities

Langfuse captures the full request lifecycle with rich detail:

Evaluation Features

Langfuse supports multiple evaluation approaches:

Integrations

Langfuse provides native integrations with the major LLM frameworks:

Code Example

from langfuse import Langfuse
from langfuse.decorators import observe, langfuse_context
from openai import OpenAI
 
langfuse = Langfuse(
    public_key="pk-lf-...",
    secret_key="sk-lf-...",
    host="https://cloud.langfuse.com"  # or self-hosted URL
)
client = OpenAI()
 
@observe()
def retrieve_context(query: str) -> str:
    """Retrieve relevant context for the query."""
    # Your retrieval logic here
    langfuse_context.update_current_observation(
        metadata={"retriever": "hybrid", "top_k": 5}
    )
    return "Retrieved context about the topic..."
 
@observe()
def generate_answer(query: str) -> str:
    """Full RAG pipeline with automatic tracing."""
    context = retrieve_context(query)
 
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[
            {"role": "system", "content": f"Context: {context}"},
            {"role": "user", "content": query}
        ]
    )
 
    # Score the trace
    langfuse_context.score_current_trace(
        name="relevance", value=0.9,
        comment="High relevance to query"
    )
    return response.choices[0].message.content
 
answer = generate_answer("How does RAG work?")
print(answer)
langfuse.flush()  # Ensure all events are sent

References

See Also