Update configuration settings and logging behavior for SQL monitoring

- Increased thresholds for maximum query and method executions per window to 500 and 250, respectively, to reduce false positives in loop detection.
- Enabled logging of slow queries only, improving performance by reducing log volume.
- Adjusted SQL query logging to capture only warnings and errors, further optimizing logging efficiency.
- Updated various settings across appsettings files to reflect these changes, ensuring consistency in configuration.
This commit is contained in:
2025-11-24 01:02:53 +07:00
parent 372d19f840
commit fef66f6d7b
10 changed files with 56 additions and 53 deletions

View File

@@ -73,8 +73,8 @@ public class SqlLoopDetectionService
var isLoopDetected = false;
var reasons = new List<string>();
// Check execution frequency
if (executionsPerMinute > 20)
// Check execution frequency (increased threshold to reduce false positives)
if (executionsPerMinute > 100)
{
isLoopDetected = true;
reasons.Add($"High frequency: {executionsPerMinute:F1} executions/minute");
@@ -87,16 +87,16 @@ public class SqlLoopDetectionService
reasons.Add($"High count: {tracker.ExecutionCount} executions in {timeSinceFirst.TotalMinutes:F1} minutes");
}
// Check for rapid successive executions
if (tracker.ExecutionCount > 5 && timeSinceFirst.TotalSeconds < 10)
// Check for rapid successive executions (increased threshold to reduce false positives)
if (tracker.ExecutionCount > 20 && timeSinceFirst.TotalSeconds < 10)
{
isLoopDetected = true;
reasons.Add(
$"Rapid execution: {tracker.ExecutionCount} executions in {timeSinceFirst.TotalSeconds:F1} seconds");
}
// Check for consistently slow queries
if (tracker.ExecutionCount > 3 && tracker.AverageExecutionTime.TotalMilliseconds > 1000)
// Check for consistently slow queries (increased threshold to reduce false positives)
if (tracker.ExecutionCount > 10 && tracker.AverageExecutionTime.TotalMilliseconds > 1000)
{
isLoopDetected = true;
reasons.Add($"Consistently slow: {tracker.AverageExecutionTime.TotalMilliseconds:F0}ms average");