Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Learn/LangChain Mastery/Part 9 · 8. Production, Evaluation & Governance
Lesson 63 of 68

Tracing with LangSmith

X-Rays for your AI. Seeing inside the black box.

Derpx0610 Jan · 1 min read
LangChain Mastery
Async & High-Throughput PatternsLatency & TTFT OptimizationTracing with LangSmithRAG Evaluation BasicsFaithfulness & RelevancePrompt Injection DefenseInput & Output GuardrailsDeployment & API Serving
Contents
1. The Black Box Problem2. Distributed Tracing for LLMs3. How to Enable It4. Dataset Collection5. Summary
0% read · 1 min leftBack to top ↑
Course outline & contents0%
LangChain Mastery
Async & High-Throughput PatternsLatency & TTFT OptimizationTracing with LangSmithRAG Evaluation BasicsFaithfulness & RelevancePrompt Injection DefenseInput & Output GuardrailsDeployment & API Serving
Contents
1. The Black Box Problem2. Distributed Tracing for LLMs3. How to Enable It4. Dataset Collection5. Summary

1. The Black Box Problem

You run your chain. It outputs "I don't know." Why?

  • Did the retriever search fail?
  • Did the retrieval return documents, but they were irrelevant?
  • Did the LLM ignore the documents (Hallucination)?
  • Did the output parsing fail?

Without Tracing, you are guessing.

2. Distributed Tracing for LLMs

LangSmith (by LangChain) acts like "DataDog for LLMs." It visualizes the Tree of Execution.

  • Root: The Chat Chain
    • Child 1: Retriever (Input: "Query", Output: [Doc A, Doc B])
    • Child 2: Prompt Builder (Input: Docs, Output: Full String)
    • Child 3: LLM Call (Input: Full String, Output: "I don't know")

By looking at Child 1, you can instantly see: "Ah! The retriever returned 0 documents. That is the bug."

3. How to Enable It

It is built into LangChain. Just set environment variables.

enable_tracing.sh
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=ls__...

4. Dataset Collection

Tracing isn't just for debugging. It is for Data Collection. You can button click on a "Good Run" in LangSmith and say "Add to Dataset." Now you have a Golden Example for future testing.

5. Summary

If you deploy to production without tracing, you are flying blind. You will never know why your users are unhappy.

Key Intuition: "You cannot fix what you cannot see."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonLatency & TTFT OptimizationNext lesson →RAG Evaluation Basics