← Back to System Design Mind Map
🏗️ System DesignID: distributed-tracing-observability

Distributed Tracing & Observability

全链路分布式追踪与可观测性
🎯Core Definition
Distributed Tracing & LLM Observability (OpenTelemetry, LangSmith, Arize Phoenix, OpenLLMetry) provides the comprehensive telemetry and telemetry telemetry recording full lifecycles across production LLM and Agent pipelines; injecting a globally unique `Trace ID` and nested `Span IDs` at ingress, the framework instruments every execution stage: 1) Latency Telemetry: Time To First Token (TTFT), Time Per Output Token (TPOT), and total inference duration; 2) Cost & Token Auditing: tracking prompt tokens, completion tokens, prefix-cached tokens, and monetary cost attribution per tenant/model; 3) Runtime Payload Capture: recording fully rendered prompt templates, retrieved RAG chunk scores, Agent tool execution inputs/outputs, and safety guardrail verdicts.
💡Use Cases
Production LLM troubleshooting, debugging multi-step Agent reasoning loops/deadlocks, tenant cost chargebacks, and RAG hallucination auditing.
⚡Key Problems Solved
Classical APMs only trace raw HTTP spans, leaving LLM inference internals and multi-agent loops as opaque black boxes; LLM observability renders the full execution graph transparent from network ingress to individual token generation.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Distributed Tracing & Observability.
Use Cases
In production engineering, what are the primary use cases for Distributed Tracing & Observability and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Define the calculation formulas and hardware bottlenecks of TTFT (Time To First Token) vs TPOT (Time Per Output Token)?
2
Design OpenTelemetry-compliant semantic conventions for LLM tracing across prompt tokens, completion tokens, and tool invocations?
3
How does nested Span tree topology record Agent Thought-Action-Observation loops and trigger watchdog circuit breaks on infinite tool loops?
4
Design an inline PII masking interceptor scrubbing credit cards, passwords, and PII from prompts before persisting spans to ClickHouse/Jaeger?
5
How to integrate asynchronous RAGAS span evaluators computing live Faithfulness and Answer Relevance metrics without blocking user responses?
Updated 2026-08-14
🎯
Verify Mastery: Practice Exam Questions for "Distributed Tracing & Observability"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardContext Budgeting & Token ManagementNext Card →Async Task Queue & Decoupled State

🔗 More System Design Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/System_Design/card/distributed-tracing-observability
中文速览与面试要点

全链路分布式追踪与可观测性 (Distributed Tracing & Observability)

定义: 全链路分布式追踪与可观测性体系 (Distributed Tracing & LLM Observability Architecture,如 OpenTelemetry, LangSmith, Arize Phoenix, OpenLLMetry) 是现代复杂大模型与 Agent 系统监控调试、性能剖析与质量审计的“黑匣子记录仪”;系统在每个外部请求进入网关时生成全局唯一的 `Trace ID` 与层级 `Span ID`,跨服务无缝透传并实时捕获全生命周期埋点数据:1) 核心性能延迟指标:首字生成延迟 (Time To First Token, TTFT)、每输出 Token 生成耗时 (Time Per Output Token, TPOT)、总耗时与网络 RTT;2) 成本与 Token 消耗审计:Prompt Tokens、Completion Tokens、Cached Tokens 与各模型调用计费账单;3) 运行时状态捕获:包含 Prompt 模板完整渲染文本、RAG 检索 Chunk 列表与相似度分值、Agent 工具调用入参与返回值、以及安全护栏拦截日志。 使用场景: 生产级大模型应用故障排查、复杂多步 Agent 循环死锁诊断、LLM API 账单成本归因、以及 RAG 幻觉召回质检。 解决的问题: 传统分布式追踪只记录 RPC 耗时,无法透视大模型内部漫长的生成过程与 Agent 内部混乱的多步工具循环;LLM 专属可观测性提供了从“网络层 -> 检索层 -> 提示词层 -> Token 输出流”的全透明全链路白盒级可观测体验。

核心要点

  • 详细定义大模型服务两大黄金延迟指标:首字延迟 (TTFT: Time To First Token) 与每输出 Token 延迟 (TPOT: Time Per Output Token) 的计算公式与瓶颈分析?
  • 基于 OpenTelemetry 规范设计自定义 LLM Semantic Conventions(如 `gen_ai.system`, `gen_ai.usage.prompt_tokens`, `gen_ai.request.model`)?
  • 多步 Agent 循环中如何通过 Parent-Child Span 树状拓扑图记录 Thought Action Observation 的完整轨迹并检测死循环超时?
  • 敏感数据脱敏与隐私保护 (PII Masking):在追踪日志写入持久化存储(如 ClickHouse / Jaeger)之前,如何通过正则表达式/NER 自动遮蔽身份证、密码与银行卡?
  • 在线生成质量监控:如何将 RAGAS 评估指标(如忠实度 Faithfulness、答案相关度 Answer Relevance)作为异步 Span Evaluator 嵌入追踪流?