dd-apm
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDatadog APM
Datadog APM
Distributed tracing, service maps, and performance analysis.
分布式链路追踪、服务地图和性能分析。
Requirements
要求
Datadog Labs Pup should be installed via:
bash
go install github.com/datadog-labs/pup@latestDatadog Labs Pup 需通过以下方式安装:
bash
go install github.com/datadog-labs/pup@latestQuick Start
快速开始
bash
pup auth login
pup apm services list
pup apm traces list --service api-gateway --duration 1hbash
pup auth login
pup apm services list
pup apm traces list --service api-gateway --duration 1hServices
服务
List Services
列出服务
bash
pup apm services list
pup apm services list --env productionbash
pup apm services list
pup apm services list --env productionService Details
服务详情
bash
pup apm services get api-gateway --jsonbash
pup apm services get api-gateway --jsonService Map
服务地图
bash
undefinedbash
undefinedView dependencies
查看依赖关系
pup apm service-map --service api-gateway --json
undefinedpup apm service-map --service api-gateway --json
undefinedTraces
链路追踪
Search Traces
搜索链路
bash
undefinedbash
undefinedBy service
按服务筛选
pup apm traces list --service api-gateway --duration 1h
pup apm traces list --service api-gateway --duration 1h
Errors only
仅展示错误
pup apm traces list --service api-gateway --status error
pup apm traces list --service api-gateway --status error
Slow traces (>1s)
慢链路(耗时>1秒)
pup apm traces list --service api-gateway --min-duration 1000ms
pup apm traces list --service api-gateway --min-duration 1000ms
With specific tag
带指定标签
pup apm traces list --query "@http.url:/api/users"
undefinedpup apm traces list --query "@http.url:/api/users"
undefinedGet Trace Detail
获取链路详情
bash
pup apm traces get <trace_id> --jsonbash
pup apm traces get <trace_id> --jsonKey Metrics
核心指标
| Metric | What It Measures |
|---|---|
| Request count |
| Latency |
| Error count |
| User satisfaction |
| 指标 | 测量内容 |
|---|---|
| 请求数 |
| 延迟 |
| 错误数 |
| 用户满意度 |
⚠️ Trace Sampling
⚠️ 链路采样
Not all traces are kept. Understand sampling:
| Mode | What's Kept |
|---|---|
| Head-based | Random % at start |
| Error/Slow | All errors, slow traces |
| Retention | What's indexed (billed) |
bash
undefined并非所有链路都会被保留。 了解采样规则:
| 模式 | 保留内容 |
|---|---|
| 基于头采样 | 链路启动时按随机百分比采样 |
| 错误/慢链路 | 所有错误、慢链路全部保留 |
| 留存 | 被索引的内容(计费部分) |
bash
undefinedCheck retention filters
查看留存过滤器
pup apm retention-filters list
undefinedpup apm retention-filters list
undefinedTrace Retention Costs
链路留存成本
| Retention | Cost |
|---|---|
| Indexed spans | $$$ per million |
| Ingested spans | $ per million |
Best practice: Only index what you need for search.
| 留存类型 | 成本 |
|---|---|
| 已索引 spans | 每百万个 $$$ |
| 已摄入 spans | 每百万个 $ |
**最佳实践:**仅索引你需要搜索的内容。
Service Level Objectives
服务级别目标(SLO)
Link APM to SLOs:
bash
pup slos create \
--name "API Latency p99 < 200ms" \
--type metric \
--numerator "sum:trace.http.request.hits{service:api,@duration:<200000000}" \
--denominator "sum:trace.http.request.hits{service:api}" \
--target 99.0将APM与SLO关联:
bash
pup slos create \
--name "API Latency p99 < 200ms" \
--type metric \
--numerator "sum:trace.http.request.hits{service:api,@duration:<200000000}" \
--denominator "sum:trace.http.request.hits{service:api}" \
--target 99.0Common Queries
常用查询
| Goal | Query |
|---|---|
| Slowest endpoints | |
| Error rate | |
| Throughput | |
| 目标 | 查询语句 |
|---|---|
| 最慢接口 | |
| 错误率 | |
| 吞吐量 | |
Troubleshooting
问题排查
| Problem | Fix |
|---|---|
| No traces | Check ddtrace installed, DD_TRACE_ENABLED=true |
| Missing service | Verify DD_SERVICE env var |
| Traces not linked | Check trace headers propagated |
| High cardinality | Don't tag with user_id/request_id |
| 问题 | 解决方法 |
|---|---|
| 无链路数据 | 检查是否安装了ddtrace,DD_TRACE_ENABLED配置是否为true |
| 服务缺失 | 验证DD_SERVICE环境变量配置是否正确 |
| 链路未关联 | 检查链路头部是否正常透传 |
| 基数过高 | 不要给user_id/request_id加标签 |