LLMOps · Module 02
Observability: LangFuse & LangSmith
See what an LLM application did on every request: traces, spans, token cost and prompts with LangFuse and LangSmith, and the practices that keep tracing safe in production.
Học xong bạn làm được
- Explain why LLM applications need their own observability
- Trace an application with LangFuse
- Trace and debug a chain with LangSmith
- Apply sampling, PII masking and alerts in production
Bài học
- The Challenge of LLM Observability
Building a demo is easy; running an LLM app in production is hard, because its models are probabilistic black boxes. Observability tools such as LangFuse and LangSmith answer four production needs - seeing inside the black box, managing cost, debugging latency and assuring quality.
- LangFuse: Open Source Observability
LangFuse is a popular open-source observability tool, valued for being self-hostable. It offers tracing, prompt management, scores and cost tracking; a CallbackHandler instruments LangChain runnables and agents, and prompts can be fetched from LangFuse instead of being hard-coded.
- LangSmith: The LangChain Native Solution
LangSmith is built by the LangChain team. It is paid and commercial, but offers the deepest integration - deep tracing including retries and internal state, a playground to edit and re-run failed traces, and datasets built from production traffic - and for LangChain users it is switched on with environment variables alone.
- Comparison: LangFuse vs. LangSmith
LangFuse is open source (MIT), easy to self-host and excellent at prompt management; LangSmith is proprietary SaaS with native LangChain integration and the best edit-and-re-run debugging. Choose LangFuse for privacy, budget or non-LangChain code, LangSmith if you are all in on LangChain or LangGraph.
- Production Best Practices, the 2026 Ecosystem and Cost Optimization
In production, sample traces (100% in dev and staging, 1-5% plus high-importance traces in production), keep PII out of cloud tools, and alert on error, latency and cost spikes. Many teams run two tools, and a stack of prompt caching, semantic caching, model routing and batch processing can cut costs by 60-80%.
- Assignment: LLM Observability with LangFuse & LangSmith
LLM Observability Implementation