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.
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.
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 https://github.com/777abhi/observability-qe-roadmap.git
cd observability-qe-roadmap/tests/day4-latency-budgets.spec.tsEvaluate Latency Budgets & Waterfalls
Run Day 4 Vitest suites and inspect percentile calculations.
npm run test:day4export 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,
};
}
}- 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?