THINK FIRST·CODE LATER

← All labs

Error-budget tracker

Problem

Track StudyBuddy's availability error budget.

Input: first line sloPercent windowDays (e.g. 99.5 30). Then incidents, one per line: name minutesDown, until the end of input.

Compute the budget in minutes: (100 - slo) / 100 * windowDays * 24 * 60. Process the incidents in order; after each print

name: -m min, remaining r min (p% used)

with r and p printed with one decimal (r may become negative). Finally print the achieved availability Availability: a% (three decimals; 100 * (1 - totalDown / windowMinutes)) and the policy:

  • Policy: SHIP (budget healthy) if less than 50% of the budget is used;
  • Policy: CAUTION (canary releases only) if 50% to 100% is used (100% exactly counts as caution);
  • Policy: FREEZE (reliability work only) if more than 100% is used.

Input:

99.5 30
login-outage 90
buddy-timeouts 45
db-migration 60

Output:

Budget: 216.0 min
login-outage: -90 min, remaining 126.0 min (41.7% used)
buddy-timeouts: -45 min, remaining 81.0 min (62.5% used)
db-migration: -60 min, remaining 21.0 min (90.3% used)
Availability: 99.549%
Policy: CAUTION (canary releases only)

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.