HomeRoadmapsObservability Day 4
Observability-Driven QE Track Β· Day 4 Β· 20 min

Latency Regression & Duration Budgets
Observability-Driven QE Sprint β€” Day 4

Calculate statistical duration percentiles (p50, p95, p99) across critical path spans, enforce latency regression budgets, and detect sequential waterfall bottlenecks.

⚑ Runtime: Node.js 22 LTS Β· VitestπŸ›‘οΈ Observability & Distributed Systems QE Architect
Latency BudgetsPercentilesp95 SLAWaterfall DetectionCritical Path
About this lab

Performance regressions often sneak in unnoticed as single slow database queries or sequential await waterfalls. In this lab, you build a latency budget evaluator that calculates exact $p50$, $p95$, and $p99$ percentiles on individual spans and fails the test if a critical span exceeds its budgeted duration.

πŸ“¦Sample Codebase & Working Solution (Day 4)Available Now
View on GitHub

The official reference codebase for Day 4 is hosted in the repository. Clone the repository and navigate to tests/day4-latency-budgets.spec.ts to run the working solution.

Git Clone β€” Working Solution
git clone https://github.com/777abhi/observability-qe-roadmap.git
cd observability-qe-roadmap/tests/day4-latency-budgets.spec.ts
🏭Production Context & Enterprise Implementation
πŸ’‘ Why We Are Doing This: A feature branch that converts two parallel API calls into sequential await steps doubles end-to-end response time. Concurrency ratio analysis spots the regression before merge.
🏒 Real-World Production Usecase: Enforcing that database query spans never exceed 80ms at p95 and that checkout total latency remains below 250ms.
βš™οΈ How Implemented in Production: LatencyBudgetEvaluator computing rank-based percentiles and BottleneckDetector calculating concurrency ratios.
Phase 1

Evaluate Latency Budgets & Waterfalls

Run Day 4 Vitest suites and inspect percentile calculations.

Step 4.1: Run Day 4 Tests
Terminal β€” Run Day 4 Tests
npm run test:day4
Step 4.2: Sample Codebase & Working Solution (Day 4)
src/latency/latencyBudgetEvaluator.ts
export class LatencyBudgetEvaluator {
  static evaluate(spans: TraceSpanRecord[], budget: LatencyBudgetConfig): BudgetEvaluationResult {
    const filtered = spans.filter((s) => !budget.spanName || s.name === budget.spanName);
    const percentiles = this.calculatePercentiles(filtered.map((s) => s.durationMs));

    const violations: string[] = [];
    if (percentiles.p95 > budget.p95MaxMs) {
      violations.push(`p95 latency ${percentiles.p95}ms exceeded budget of ${budget.p95MaxMs}ms`);
    }

    return {
      passed: violations.length === 0,
      actualPercentiles: percentiles,
      budget,
      violations,
    };
  }
}
Day 4 Key Learnings
  • Calculated exact statistical p50, p95, and p99 percentiles over trace duration distributions.
  • Enforced granular latency regression budgets per microservice span.
  • Detected synchronous waterfall bottlenecks where operations blocked sequentially rather than executing concurrently.

🧠 Knowledge Check

What does a concurrency ratio of exactly 1.0 indicate in trace analysis?