AlgoMaster Logo
AlgoMasterAnalyze Canary Health Windowsmedium

Analyze Canary Health Windows

medium

Automated canary analysis observes several time windows rather than trusting one small sample. Promotion requires sustained health, while one conclusive regression stops the rollout.

Design a CanaryWindowAnalyzer:

  • The constructor receives minRequests, an allowed error-rate increase in percentage points, an allowed p95 latency increase in percent, and the required number of consecutive healthy windows.
  • evaluate(...) returns "promote", "rollback", or "continue".
  • decisionWindow(...) returns the zero-based window that produced promotion or rollback, or -1 for continue.

A window is eligible only when both versions have at least minRequests. An ineligible window resets the healthy streak.

An eligible window is unhealthy when either:

or:

Equality is healthy. Roll back immediately on the first unhealthy eligible window. Otherwise promote at the first required consecutive healthy window and ignore later windows.

Example 1:

Input:

Output:

Explanation: Two consecutive eligible windows stay within both thresholds.

Example 2:

Input:

Output:

Explanation: The second window exceeds the error threshold, so the rollout stops before it can collect three healthy windows.

Constraints

  • All six input arrays have equal length, at most 10^4.
  • Request totals and p95 values are positive integers.
  • Error counts are between zero and their request totals.
  • Thresholds are non-negative integers.
  • 1 <= requiredHealthyWindows <= 100
  • Cross-products fit signed 64-bit integers.
  • At most 50 total method calls are made.
Hints

Loading...
CallReturns
new CanaryWindowAnalyzer(100, 2, 10, 2)null
evaluate([4,3], [100,100], [2,2], [100,100], [105,108], [100,100])"promote"
decisionWindow([4,3], [100,100], [2,2], [100,100], [105,108], [100,100])1

Both eligible windows are within the error and latency thresholds. The second consecutive healthy window triggers promotion.

Run checks these cases. Submit also runs a larger hidden set.