quality-metrics
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQuality Metrics
质量指标
<default_to_action>
When measuring quality or building dashboards:
- MEASURE outcomes (bug escape rate, MTTD) not activities (test count)
- FOCUS on DORA metrics: Deployment frequency, Lead time, MTTD, MTTR, Change failure rate
- AVOID vanity metrics: 100% coverage means nothing if tests don't catch bugs
- SET thresholds that drive behavior (quality gates block bad code)
- TREND over time: Direction matters more than absolute numbers
Quick Metric Selection:
- Speed: Deployment frequency, lead time for changes
- Stability: Change failure rate, MTTR
- Quality: Bug escape rate, defect density, test effectiveness
- Process: Code review time, flaky test rate
Critical Success Factors:
- Metrics without action are theater
- What you measure is what you optimize
- Trends matter more than snapshots </default_to_action>
<default_to_action>
在衡量质量或搭建仪表盘时:
- 衡量结果指标(bug逃逸率、MTTD)而非活动指标(测试用例数量)
- 聚焦DORA指标:部署频率、前置时间、MTTD、MTTR、变更失败率
- 避免虚荣指标:如果测试无法发现bug,100%覆盖率毫无意义
- 设置能驱动行为的阈值(质量门禁拦截不良代码)
- 追踪长期趋势:趋势方向比绝对数值更重要
快速指标选择:
- 速度:部署频率、变更前置时间
- 稳定性:变更失败率、MTTR
- 质量:bug逃逸率、缺陷密度、测试有效性
- 流程:代码评审时长、不稳定测试率
关键成功因素:
- 无行动支撑的指标只是形式主义
- 你衡量什么,就会优化什么
- 趋势比快照更重要 </default_to_action>
Quick Reference Card
快速参考卡片
When to Use
适用场景
- Building quality dashboards
- Defining quality gates
- Evaluating testing effectiveness
- Justifying quality investments
- 搭建质量仪表盘
- 定义质量门禁
- 评估测试有效性
- 论证质量投入的合理性
Meaningful vs Vanity Metrics
有意义指标 vs 虚荣指标
| ✅ Meaningful | ❌ Vanity |
|---|---|
| Bug escape rate | Test case count |
| MTTD (detection) | Lines of test code |
| MTTR (recovery) | Test executions |
| Change failure rate | Coverage % (alone) |
| Lead time for changes | Requirements traced |
| ✅ 有意义指标 | ❌ 虚荣指标 |
|---|---|
| Bug逃逸率 | 测试用例数量 |
| MTTD(检测时长) | 测试代码行数 |
| MTTR(恢复时长) | 测试执行次数 |
| 变更失败率 | 单独的覆盖率百分比 |
| 变更前置时间 | 需求追踪数 |
DORA Metrics
DORA指标
| Metric | Elite | High | Medium | Low |
|---|---|---|---|---|
| Deploy Frequency | On-demand | Weekly | Monthly | Yearly |
| Lead Time | < 1 hour | < 1 week | < 1 month | > 6 months |
| Change Failure Rate | < 5% | < 15% | < 30% | > 45% |
| MTTR | < 1 hour | < 1 day | < 1 week | > 1 month |
| 指标 | 精英级 | 高级 | 中级 | 低级 |
|---|---|---|---|---|
| 部署频率 | 按需部署 | 每周 | 每月 | 每年 |
| 前置时间 | < 1小时 | < 1周 | < 1个月 | > 6个月 |
| 变更失败率 | < 5% | < 15% | < 30% | > 45% |
| MTTR | < 1小时 | < 1天 | < 1周 | > 1个月 |
Quality Gate Thresholds
质量门禁阈值
| Metric | Blocking Threshold | Warning |
|---|---|---|
| Test pass rate | 100% | - |
| Critical coverage | > 80% | > 70% |
| Security critical | 0 | - |
| Performance p95 | < 200ms | < 500ms |
| Flaky tests | < 2% | < 5% |
| 指标 | 拦截阈值 | 警告阈值 |
|---|---|---|
| 测试通过率 | 100% | - |
| 核心覆盖率 | > 80% | > 70% |
| 严重安全问题 | 0 | - |
| 性能p95 | < 200ms | < 500ms |
| 不稳定测试率 | < 2% | < 5% |
Core Metrics
核心指标
Bug Escape Rate
Bug逃逸率
Bug Escape Rate = (Production Bugs / Total Bugs Found) × 100
Target: < 10% (90% caught before production)Bug Escape Rate = (生产环境发现的Bug总数 / 发现的所有Bug总数) × 100
目标:< 10%(90%的Bug在生产前被发现)Test Effectiveness
测试有效性
Test Effectiveness = (Bugs Found by Tests / Total Bugs) × 100
Target: > 70%Test Effectiveness = (测试发现的Bug数 / 所有Bug总数) × 100
目标:> 70%Defect Density
缺陷密度
Defect Density = Defects / KLOC
Good: < 1 defect per KLOCDefect Density = 缺陷数 / KLOC(千行代码)
合格标准:< 1个缺陷/千行代码Mean Time to Detect (MTTD)
平均检测时长(MTTD)
MTTD = Time(Bug Reported) - Time(Bug Introduced)
Target: < 1 day for critical, < 1 week for othersMTTD = Bug上报时间 - Bug引入时间
目标:严重Bug < 1天,其他Bug < 1周Dashboard Design
仪表盘设计
typescript
// Agent generates quality dashboard
await Task("Generate Dashboard", {
metrics: {
delivery: ['deployment-frequency', 'lead-time', 'change-failure-rate'],
quality: ['bug-escape-rate', 'test-effectiveness', 'defect-density'],
stability: ['mttd', 'mttr', 'availability'],
process: ['code-review-time', 'flaky-test-rate', 'coverage-trend']
},
visualization: 'grafana',
alerts: {
critical: { bug_escape_rate: '>20%', mttr: '>24h' },
warning: { coverage: '<70%', flaky_rate: '>5%' }
}
}, "qe-quality-analyzer");typescript
// Agent生成质量仪表盘
await Task("Generate Dashboard", {
metrics: {
delivery: ['deployment-frequency', 'lead-time', 'change-failure-rate'],
quality: ['bug-escape-rate', 'test-effectiveness', 'defect-density'],
stability: ['mttd', 'mttr', 'availability'],
process: ['code-review-time', 'flaky-test-rate', 'coverage-trend']
},
visualization: 'grafana',
alerts: {
critical: { bug_escape_rate: '>20%', mttr: '>24h' },
warning: { coverage: '<70%', flaky_rate: '>5%' }
}
}, "qe-quality-analyzer");Quality Gate Configuration
质量门禁配置
json
{
"qualityGates": {
"commit": {
"coverage": { "min": 80, "blocking": true },
"lint": { "errors": 0, "blocking": true }
},
"pr": {
"tests": { "pass": "100%", "blocking": true },
"security": { "critical": 0, "blocking": true },
"coverage_delta": { "min": 0, "blocking": false }
},
"release": {
"e2e": { "pass": "100%", "blocking": true },
"performance_p95": { "max_ms": 200, "blocking": true },
"bug_escape_rate": { "max": "10%", "blocking": false }
}
}
}json
{
"qualityGates": {
"commit": {
"coverage": { "min": 80, "blocking": true },
"lint": { "errors": 0, "blocking": true }
},
"pr": {
"tests": { "pass": "100%", "blocking": true },
"security": { "critical": 0, "blocking": true },
"coverage_delta": { "min": 0, "blocking": false }
},
"release": {
"e2e": { "pass": "100%", "blocking": true },
"performance_p95": { "max_ms": 200, "blocking": true },
"bug_escape_rate": { "max": "10%", "blocking": false }
}
}
}Agent-Assisted Metrics
Agent辅助指标分析
typescript
// Calculate quality trends
await Task("Quality Trend Analysis", {
timeframe: '90d',
metrics: ['bug-escape-rate', 'mttd', 'test-effectiveness'],
compare: 'previous-90d',
predictNext: '30d'
}, "qe-quality-analyzer");
// Evaluate quality gate
await Task("Quality Gate Evaluation", {
buildId: 'build-123',
environment: 'staging',
metrics: currentMetrics,
policy: qualityPolicy
}, "qe-quality-gate");typescript
// 计算质量趋势
await Task("Quality Trend Analysis", {
timeframe: '90d',
metrics: ['bug-escape-rate', 'mttd', 'test-effectiveness'],
compare: 'previous-90d',
predictNext: '30d'
}, "qe-quality-analyzer");
// 评估质量门禁
await Task("Quality Gate Evaluation", {
buildId: 'build-123',
environment: 'staging',
metrics: currentMetrics,
policy: qualityPolicy
}, "qe-quality-gate");Agent Coordination Hints
Agent协作提示
Memory Namespace
内存命名空间
aqe/quality-metrics/
├── dashboards/* - Dashboard configurations
├── trends/* - Historical metric data
├── gates/* - Gate evaluation results
└── alerts/* - Triggered alertsaqe/quality-metrics/
├── dashboards/* - 仪表盘配置
├── trends/* - 历史指标数据
├── gates/* - 门禁评估结果
└── alerts/* - 触发的告警Fleet Coordination
集群协作
typescript
const metricsFleet = await FleetManager.coordinate({
strategy: 'quality-metrics',
agents: [
'qe-quality-analyzer', // Trend analysis
'qe-test-executor', // Test metrics
'qe-coverage-analyzer', // Coverage data
'qe-production-intelligence', // Production metrics
'qe-quality-gate' // Gate decisions
],
topology: 'mesh'
});typescript
const metricsFleet = await FleetManager.coordinate({
strategy: 'quality-metrics',
agents: [
'qe-quality-analyzer', // 趋势分析
'qe-test-executor', // 测试指标
'qe-coverage-analyzer', // 覆盖率数据
'qe-production-intelligence', // 生产环境指标
'qe-quality-gate' // 门禁决策
],
topology: 'mesh'
});Common Traps
常见误区
| Trap | Problem | Solution |
|---|---|---|
| Coverage worship | 100% coverage, bugs still escape | Measure bug escape rate instead |
| Test count focus | Many tests, slow feedback | Measure execution time |
| Activity metrics | Busy work, no outcomes | Measure outcomes (MTTD, MTTR) |
| Point-in-time | Snapshot without context | Track trends over time |
| 误区 | 问题 | 解决方案 |
|---|---|---|
| 覆盖率崇拜 | 覆盖率100%但仍有Bug逃逸 | 转而衡量Bug逃逸率 |
| 关注测试数量 | 测试用例多但反馈缓慢 | 衡量测试执行时长 |
| 活动类指标 | 看似忙碌但无实际成果 | 衡量结果指标(MTTD、MTTR) |
| 单点时间快照 | 无上下文的静态数据 | 追踪长期趋势 |
Related Skills
相关技能
- agentic-quality-engineering - Agent coordination
- cicd-pipeline-qe-orchestrator - Quality gates
- risk-based-testing - Risk-informed metrics
- shift-right-testing - Production metrics
- agentic-quality-engineering - Agent协作
- cicd-pipeline-qe-orchestrator - 质量门禁
- risk-based-testing - 风险导向型指标
- shift-right-testing - 生产环境指标
Remember
谨记
Measure outcomes, not activities. Bug escape rate > test count. MTTD/MTTR > coverage %. Trends > snapshots. Set gates that block bad code. What you measure is what you optimize.
With Agents: Agents track metrics automatically, analyze trends, trigger alerts, and make gate decisions. Use agents to maintain continuous quality visibility.
衡量结果,而非活动。 Bug逃逸率比测试用例数量更重要。MTTD/MTTR比覆盖率百分比更重要。趋势比快照更重要。设置能拦截不良代码的质量门禁。你衡量什么,就会优化什么。
借助Agent: Agent可自动追踪指标、分析趋势、触发告警并做出门禁决策。使用Agent持续监控质量状况。