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:
@@ -768,12 +768,14 @@ public class ManagingDbContext : DbContext
|
||||
// Check for potential loops with Sentry integration
|
||||
var isLoopDetected = _sentryMonitoringService.TrackQueryExecution(repositoryName, methodName, queryPattern, executionTime);
|
||||
|
||||
// Log query execution details
|
||||
var logLevel = executionTime.TotalMilliseconds > 1000 ? LogLevel.Warning : LogLevel.Debug;
|
||||
_logger.Log(logLevel,
|
||||
"[SQL-QUERY-TRACKED] {Repository}.{Method} | Pattern: {Pattern} | Time: {Time}ms | Count: {Count}",
|
||||
repositoryName, methodName, queryPattern, executionTime.TotalMilliseconds,
|
||||
_queryExecutionCounts[queryPattern]);
|
||||
// Only log query execution details if it should be logged based on monitoring settings
|
||||
if (_sentryMonitoringService.ShouldLogQuery(executionTime))
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"[SQL-QUERY-TRACKED] {Repository}.{Method} | Pattern: {Pattern} | Time: {Time}ms | Count: {Count}",
|
||||
repositoryName, methodName, queryPattern, executionTime.TotalMilliseconds,
|
||||
_queryExecutionCounts[queryPattern]);
|
||||
}
|
||||
|
||||
// Alert on potential loops
|
||||
if (isLoopDetected)
|
||||
|
||||
Reference in New Issue
Block a user