AI AgentObservability
What you need to know about observability when you live among agents.
I wrote this book to help you take a TypeScript AI agent from fragile localhost scripts to observable production systems, with 36 runnable examples in Firebase Genkit, LangChain + LangSmith, Progress Observability Platform, and OpenTelemetry.
When it works or fails,do you know why?
Today we use AI to write code and build agents. When an agent works or fails, we often do not know what happened behind the scenes. In this book, I show you how to answer what it did, why it failed, and what it cost.
Silent 200 OK & Prompt Injection
A policy check breaks or an injection slips past filters, and server logs still report 200 OK.
The Token Snowball
Multi-turn ReAct loops resend full history and reasoning tokens on every step until latency and cost spike.
Prompt Roulette
You edit two lines in a system prompt to fix one case, and three other tool flows quietly break.
Scale, PII & MCP Gaps
Blind async hops across MCP servers, client aborts logged as 500 errors, and unmasked payment data in raw traces.
| Dimension | Prompting Blindly | Observable Engineering (This Book) |
|---|---|---|
| Visibility | Flat logs that lose context across async tool calls | Full trace trees across Genkit, LangSmith, Progress & OTel |
| Cost & Loops | Surprise API invoice at the end of the month | Per-run token/USD accounting, prefix caching, and hard loop caps |
| Quality & Evals | Testing 3 prompts by hand after each edit | Golden Datasets, calibrated LLM judges, and CI/CD trajectory gates |
| Production Safety | Raw PII in traces and brittle multi-agent hops | 4-layer PII redaction, HITL approvals, W3C MCP traces & circuit breakers |
Four complementary technologies
Vendor-neutral foundations alongside real platform instrumentation.
Firebase Genkit
Trace defineFlow, defineTool, and ai.run spans on localhost:4000, then monitor P95 latency in Genkit Monitoring.
LangChain v1 & LangSmith
Inspect createAgent loops, run Golden Dataset experiments in CI/CD, filter traffic with FQL, and add HITL and PII middlewares.
Progress Observability Platform
Instrument @progress/observability for enterprise telemetry, real-time FinOps USD cost analytics, and automated LLM-as-a-Judge checks.
OpenTelemetry (gen_ai.*)
Emit portable spans, tune BatchSpanProcessor backpressure, and propagate W3C traceparent and baggage across MCP servers.
What is inside the book
Five parts that take you from initial setup to production guardrails.
Setup & Foundations
- 00Before You Start: The Pieces on the Map and Environment Setup
- 01Coding Agents Building Agents... and It Worked. Now What?
- 02What an Agent Really Is: Model, Messages, Tools, Memory, and Loop
- 03Why Your Usual Logs Aren't Enough: From Flat Logs to Traces and Spans
- 04Tokens, Latency, and Cost: The Bill Nobody Explained to You
The Instrumentation Pillars
- 05Your First Trace with Genkit: Your Agent's "DevTools"
- 06Your First Trace with LangChain + LangSmith
- 07Anatomy of a Trace: Run Types, Metadata, Tags, and Threads
- 08Progress Observability Platform: Traces, FinOps Costs, and LLM-as-a-Judge
- 09OpenTelemetry Without Fear: The Standard Under All Three
Evaluation and Quality
- 10"It Seems to Work" Is Not a Metric: Datasets
- 11Evaluators: Code, LLM-as-a-Judge, and Their Traps
- 12Experiments: Changing the Prompt or Model Without Breaking Anything
- 13Evaluating Agents, Not Only Answers: Trajectory and Loops
- 14User Feedback and Human Annotation Queues
- 15Finding the Needle: Filtering Production Traces for Errors & Latency
Production Operations and Scale
- 16Online Evaluation and Automations
- 17Genkit Monitoring, Dashboards, and Alerts
- 18Privacy and Security: What NOT to Store in Your Traces
- 19Production Architecture and Choosing Your Stack
- 20How to Ask Your AI Assistant for an Observable Agent from Day 1
Advanced Production Patterns
- 21Multi-Agent and MCP Observability
- 22Streaming and Real-Time Observability
- 23Semantic Caching, Guardrails, and Circuit Breakers
Reference & Checklists
- ABilingual Observability Glossary (ES / EN)
- B20-Point Production Observability Checklist
- CCompanion Repository & CLI Reference
- DFour Pillars & OpenTelemetry Cheat Sheet
Choose your edition
Read the free sample first or get the full digital edition on Leanpub.
Free Sample + Repository
Download the 47-page preview (Front Matter and Chapters 0 to 2) plus access to the companion TypeScript repository.
- PDF and EPUB 3 sample sent to your inbox
- 36 runnable TypeScript examples (Genkit, LangChain, OTel)
- AGENTS.md, .cursorrules, CLAUDE.md & GEMINI.md pack
Digital Edition (PDF + EPUB 3)
Complete v1.1.0 book (264 pp. EN / 250 pp. ES) with all chapters, appendices, and future updates.
- All 24 chapters and 4 reference appendices
- Screenshots and traces from Genkit, LangSmith & Progress
- DRM-free PDF and EPUB 3 files
Extra resources & templates
Download the 3 ready-to-use Markdown templates referenced throughout the book.
OpenTelemetry gen_ai.* Cheat Sheet
One-page reference of standard span names, gen_ai.* attributes, and the Four Pillars mapping table.
20-Point Production Checklist
Pre-launch checklist for loop caps, BatchSpanProcessor, Golden Datasets, PII redaction, and HITL gates.
AI Assistant Rules Pack
Copy-paste templates for AGENTS.md, .cursorrules, CLAUDE.md, and GEMINI.md so your AI builds observable agents from day 1.