distributed-tracing
它能做什么
帮助你了解请求如何在计算机系统的不同部分之间流转。这对于查找性能缓慢或错误的原因非常有用。
适用场景
- ✓当某些操作很慢时
- ✓当你想查看服务之间如何通信时
- ✓当你想找出错误发生的位置时
技能链接
https://github.com/wshobson/agents/blob/main/plugins/observability-monitoring/skills/distributed-tracing/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“帮我追踪一个处理时间过长的请求。”
每周 5 个新技能,1 分钟读完。
工作原理
它的工作方式是在请求经过的每个步骤中添加一小段信息。这些信息会被发送到一个可以查看请求完整路径的地方。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Distributed Tracing
Implement distributed tracing with Jaeger and Tempo for request flow visibility across microservices.
Purpose
Track requests across distributed systems to understand latency, dependencies, and failure points.
When to Use
- Debug latency issues
- Understand service dependencies
- Identify bottlenecks
- Trace error propagation
- Analyze request paths
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
- Sample appropriately (1-10% in production)
- Add meaningful tags (user_id, request_id)
- Propagate context across all service boundaries
- Log exceptions in spans
- Use consistent naming for operations
- Monitor tracing overhead (<1% CPU impact)
- Set up alerts for trace errors
- Implement distributed context (baggage)
- Use span events for important milestones
- Document instrumentation standards
Integration with Logging
Correlated Logs
import logging
from opentelemetry import trace
logger = logging.getLogger(__name__)
def process_request():
span = trace.get_current_span()
trace_id = span.get_span_context().trace_id
logger.info(
"Processing request",
extra={"trace_id": format(trace_id, '032x')}
)
Troubleshooting
No traces appearing:
- Check collector endpoint
- Verify network connectivity
- Check sampling configuration
- Review application logs
High latency overhead:
- Reduce sampling rate
- Use batch span processor
- Check exporter configuration
Related Skills
prometheus-configuration- For metricsgrafana-dashboards- For visualizationslo-implementation- For latency SLOs
常见问题
什么是“微服务”?
它们就像一个大型程序中相互独立的小部件,彼此之间通过通信协作。
“Jaeger”或“Tempo”是什么?
它们是用于收集和展示追踪信息的工具,方便我们将其可视化。
为什么要对追踪进行“采样”?
为了避免系统被海量信息淹没,尤其是在请求量很大的大型系统中。
详情
作者的原始描述
Implement distributed tracing with Jaeger and Tempo to track requests across microservices and identify performance bottlenecks. Use when debugging microservices, analyzing request flows, or implementing observability for distributed systems.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6740
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …