@@ -60,7 +60,6 @@ public partial class MainWindow : Window
6060 private readonly ConcurrentDictionary < string , DateTime > _lastBlockingAlert = new ( ) ;
6161 private readonly ConcurrentDictionary < string , DateTime > _lastDeadlockAlert = new ( ) ;
6262 private readonly ConcurrentDictionary < string , DateTime > _lastHighCpuAlert = new ( ) ;
63- private static readonly TimeSpan AlertCooldown = TimeSpan . FromMinutes ( 5 ) ;
6463 private readonly ConcurrentDictionary < string , bool > _activeBlockingAlert = new ( ) ;
6564 private readonly ConcurrentDictionary < string , bool > _activeDeadlockAlert = new ( ) ;
6665 private readonly ConcurrentDictionary < string , bool > _activeHighCpuAlert = new ( ) ;
@@ -1097,6 +1096,7 @@ private async Task EvaluateAlertConditionsAsync(
10971096 string serverId , string serverName , AlertHealthResult health , DatabaseService databaseService )
10981097 {
10991098 var prefs = _preferencesService . GetPreferences ( ) ;
1099+ var alertCooldown = TimeSpan . FromMinutes ( prefs . AlertCooldownMinutes ) ;
11001100
11011101 if ( _alertStateService . IsAnySilencingActive ( serverId ) )
11021102 {
@@ -1112,7 +1112,7 @@ private async Task EvaluateAlertConditionsAsync(
11121112 if ( blockingExceeded )
11131113 {
11141114 _activeBlockingAlert [ serverId ] = true ;
1115- if ( ! _lastBlockingAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= AlertCooldown )
1115+ if ( ! _lastBlockingAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= alertCooldown )
11161116 {
11171117 _notificationService ? . ShowBlockingNotification (
11181118 serverName ,
@@ -1158,7 +1158,7 @@ await _emailAlertService.TrySendAlertEmailAsync(
11581158 if ( deadlocksExceeded )
11591159 {
11601160 _activeDeadlockAlert [ serverId ] = true ;
1161- if ( ! _lastDeadlockAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= AlertCooldown )
1161+ if ( ! _lastDeadlockAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= alertCooldown )
11621162 {
11631163 _notificationService ? . ShowDeadlockNotification (
11641164 serverName ,
@@ -1197,7 +1197,7 @@ await _emailAlertService.TrySendAlertEmailAsync(
11971197 {
11981198 var totalCpu = health . TotalCpuPercent ! . Value ;
11991199 _activeHighCpuAlert [ serverId ] = true ;
1200- if ( ! _lastHighCpuAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= AlertCooldown )
1200+ if ( ! _lastHighCpuAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= alertCooldown )
12011201 {
12021202 _notificationService ? . ShowHighCpuNotification (
12031203 serverName ,
@@ -1233,7 +1233,7 @@ await _emailAlertService.TrySendAlertEmailAsync(
12331233 if ( triggeredWaits . Count > 0 )
12341234 {
12351235 _activePoisonWaitAlert [ serverId ] = true ;
1236- if ( ! _lastPoisonWaitAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= AlertCooldown )
1236+ if ( ! _lastPoisonWaitAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= alertCooldown )
12371237 {
12381238 var worst = triggeredWaits [ 0 ] ;
12391239 _notificationService ? . ShowPoisonWaitNotification ( serverName , worst . WaitType , worst . AvgMsPerWait ) ;
@@ -1270,7 +1270,7 @@ await _emailAlertService.TrySendAlertEmailAsync(
12701270 if ( longRunningTriggered )
12711271 {
12721272 _activeLongRunningQueryAlert [ serverId ] = true ;
1273- if ( ! _lastLongRunningQueryAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= AlertCooldown )
1273+ if ( ! _lastLongRunningQueryAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= alertCooldown )
12741274 {
12751275 var worst = health . LongRunningQueries [ 0 ] ;
12761276 var elapsedMinutes = worst . ElapsedSeconds / 60 ;
@@ -1311,7 +1311,7 @@ await _emailAlertService.TrySendAlertEmailAsync(
13111311 {
13121312 var tempDb = health . TempDbSpace ! ;
13131313 _activeTempDbSpaceAlert [ serverId ] = true ;
1314- if ( ! _lastTempDbSpaceAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= AlertCooldown )
1314+ if ( ! _lastTempDbSpaceAlert . TryGetValue ( serverId , out var lastAlert ) || ( now - lastAlert ) >= alertCooldown )
13151315 {
13161316 _notificationService ? . ShowTempDbSpaceNotification ( serverName , tempDb . UsedPercent ) ;
13171317 _lastTempDbSpaceAlert [ serverId ] = now ;
@@ -1350,7 +1350,7 @@ await _emailAlertService.TrySendAlertEmailAsync(
13501350 var worst = health . AnomalousJobs [ 0 ] ;
13511351 var jobKey = $ "{ serverId } :{ worst . JobId } :{ worst . StartTime : O} ";
13521352
1353- if ( ! _lastLongRunningJobAlert . TryGetValue ( jobKey , out var lastAlert ) || ( now - lastAlert ) >= AlertCooldown )
1353+ if ( ! _lastLongRunningJobAlert . TryGetValue ( jobKey , out var lastAlert ) || ( now - lastAlert ) >= alertCooldown )
13541354 {
13551355 var currentMinutes = worst . CurrentDurationSeconds / 60 ;
13561356 _notificationService ? . ShowLongRunningJobNotification (
0 commit comments