PIXELBANKv9.1.0
Menu

Problem Statement

Implement a multi-window burn-rate alert: fire only when the error budget is being consumed too fast over both a long and a short window (to catch fast burns while avoiding flapping).

Background

Burn rate = observed_error_rate / (1 - slo) — how many times faster than sustainable the budget is being spent. A page fires when the burn rate exceeds threshold over the long window AND over the short window simultaneously. Given error rates for each window, decide whether to alert.

Your Task

def burn_alert(slo, long_err_rate, short_err_rate, threshold):

Return True if both windows' burn rates exceed threshold, else False.

Input Format

  • slo (float), long_err_rate, short_err_rate (float), threshold (float).

Output Format

  • A boolean.

Sample

print(burn_alert(0.99, 0.15, 0.20, 10.0))

Output:

True

Example:

Input:
print(burn_alert(0.99, 0.15, 0.20, 10.0))
Output:
True
Reasoning:
  • Calculate the sustainable error budget rate by subtracting the SLO from 1, representing the maximum acceptable error fraction: 1−0.99=0.011 - 0.99 = 0.01.
  • Determine the long-window burn rate by dividing the observed long error rate by the budget rate to see how many times faster the budget is being consumed: 0.15/0.01=150.15 / 0.01 = 15.
  • Determine the short-window burn rate by dividing the observed short error rate by the budget rate: 0.20/0.01=200.20 / 0.01 = 20.
  • Evaluate the alert condition, which requires both burn rates to strictly exceed the threshold of 10.010.0: 15>10.015 > 10.0 is true and 20>10.020 > 10.0 is true.
  • The final output is True

Constraints:

  • burn = err_rate / (1 - slo).
  • Alert only if BOTH long and short burn > threshold.
  • Return a bool.
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.