7 views
This guide focuses on LLM observability for production systems, with practical trade-offs for reliability, security, and cost.
“The agent was weird” is not a bug report. You need a trace_id that stitches prompt build, retrieval, model latency, tool calls, and citation gate decisions into one waterfall. Day 39 defines the minimum span set and redaction rules.
⚡ TL;DR: One trace per user turn. Spans:retrieve,prompt.build,converse,tool.*,cite.gate. Attributes for model id, index sha, tokens — not secrets. 100% sample errors.
LLM observability: production guidance
python
from opentelemetry import trace
tracer = trace.get_tracer("ai.gateway")
def handle_turn(req):
with tracer.start_as_current_span("agent.turn") as root:
root.set_attribute("session.id", req.session_id)
with tracer.start_as_current_span("retrieve") as sp:
chunks = retrieve(req.question)
sp.set_attribute("retrieve.k", len(chunks))
sp.set_attribute("index.sha", INDEX_SHA)
with tracer.start_as_current_span("converse") as sp:
sp.set_attribute("model.id", MODEL)
out = converse(...)
sp.set_attribute("usage.input_tokens", out["usage"]["inputTokens"])
with tracer.start_as_current_span("cite.gate") as sp:
gated = gate(out, chunks)
sp.set_attribute("cite.ok", not gated.get("refuse"))
return gated
failure.cls from Day 29 when known.
Production checklist
- [ ] W3C
traceparentthrough API → workers - [ ] Span attribute schema documented
- [ ] PII/secret redaction reviewed
- [ ] Trace-linked examples in Sev runbooks
- [ ] Sampling: 100% errors, partial success
- [ ] Support tool can replay retrieval ids by trace
Series navigation
← Day 38 · Day 40 → Last updated September 11, 2026 Related: Bedrock Guardrails: Block Prompt Injection Inside Internal Dev Tools; OpenTelemetry for LLMs: Trace Prompt Latency Across Microservices; Day 88: Simulation and Digital Twins for Tools.Watch: 100 Days of AI on YouTube
Short videos from CheatCoders, one AI engineering topic per day.
Most viewed
- Python Decorators Explained: From Simple Wrappers to Production Patterns
- Claude Code vs Cursor vs GitHub Copilot: Choose by Workflow, and Set Up One Repo That Works With All Three
- AI Agent Frameworks in 2025: LangGraph vs CrewAI vs AutoGen vs Raw API
- Python String Methods: Every str Method With Real Production Examples
- Css Animation Performance: Performance-Optimized Motion for Modern UIs
Newly added
- AWS Systems Manager Parameter Store: Hierarchical Runtime Config for Coding Agents
- Amazon Cognito Identity Pools: Federate Coding-Agent Tool Callers Without Long-Lived Keys
- Amazon Athena for Coding Agents: Query Tool Audit Logs and Eval Traces on S3 Without a Warehouse
- AWS Batch for Coding Agents: Parallel Overnight PR Reviews and Long-Running Jobs Without Lambda Timeouts
- Amazon Bedrock Prompt Management: Version and A/B Test Coding-Agent System Prompts
Deep-dive PDF
Get the expanded guide for this post — extra diagrams-style checklists, failure modes, and a production walkthrough. Free when you subscribe to CheatCoders.
Already subscribed? or open the subscribe page.
Discover more from CheatCoders
Subscribe to get the latest posts sent to your email.
