feat(usage): split throttle thresholds per bucket, add draggable gauge markers

This commit is contained in:
mika kuns
2026-08-07 11:01:45 +02:00
parent 231b063751
commit 7eeb8f5086
33 changed files with 2289 additions and 147 deletions
@@ -49,13 +49,18 @@ public sealed class UsageSnapshotBuilder
.Select(l => new UsageLimitDto(l.Kind, l.Group, l.Percent, l.Severity, l.ResetsAt, l.ScopeModelDisplayName, l.IsActive))
.ToList();
var fiveHourThresholds = new UsageThresholds(
settings.UsageThrottleFiveHourSoftPct, settings.UsageThrottleFiveHourHardPct, settings.UsageGateFiveHourPct);
var sevenDayThresholds = new UsageThresholds(
settings.UsageThrottleSevenDaySoftPct, settings.UsageThrottleSevenDayHardPct, settings.UsageGateSevenDayPct);
var configuredSlots = Math.Max(1, settings.MaxParallelExecutions);
var effectiveSlots = snapshot is null || lastError is not null
? configuredSlots
: UsageThrottle.EffectiveSlots(
configuredSlots, snapshot.FiveHour?.Utilization, snapshot.SevenDay?.Utilization,
settings.UsageThrottleSoftPct, settings.UsageThrottleHardPct,
settings.UsageGateFiveHourPct, settings.UsageGateSevenDayPct);
configuredSlots,
snapshot.FiveHour?.Utilization, fiveHourThresholds,
snapshot.SevenDay?.Utilization, sevenDayThresholds);
var throttleBucket = effectiveSlots < configuredSlots
? DecisiveBucket(snapshot?.FiveHour?.Utilization, snapshot?.SevenDay?.Utilization)
: null;
@@ -75,7 +80,11 @@ public sealed class UsageSnapshotBuilder
lastError,
configuredSlots,
effectiveSlots,
throttleBucket);
throttleBucket,
fiveHourThresholds.SoftPct,
fiveHourThresholds.HardPct,
sevenDayThresholds.SoftPct,
sevenDayThresholds.HardPct);
}
private static string? DecisiveBucket(double? fiveHourPct, double? sevenDayPct)