Add event to warning log for matched profiles

This commit is contained in:
armirveliaj
2025-10-01 08:31:59 -04:00
committed by Dan Christian Bogos
parent e9b1538450
commit 2b63ee67bb
2 changed files with 7 additions and 4 deletions

View File

@@ -139,7 +139,8 @@ func MatchingItemIDsForEvent(ev utils.MapStorage, stringFldIDs, prefixFldIDs, su
}
if len(itemIDs) > matchedItemsWarningThreshold {
utils.Logger.Warning(fmt.Sprintf(
"Matched %d %s items. Performance may be affected", len(itemIDs), cacheID))
"Matched %d %s items. Performance may be affected.\nevent = %s",
len(itemIDs), cacheID, utils.ToJSON(ev)))
}
return
}

View File

@@ -229,7 +229,10 @@ func TestMatchingItemIDsForEventWarningThresholds(t *testing.T) {
utils.Logger.SetSyslog(nil)
var buf bytes.Buffer
log.SetOutput(&buf)
defer func() { log.SetOutput(os.Stderr) }()
t.Cleanup(func() {
utils.Logger.SetLogLevel(0)
log.SetOutput(os.Stderr)
})
cfg := config.NewDefaultCGRConfig()
data, dErr := NewInternalDB(nil, nil, true, nil, cfg.DataDbCfg().Items)
if dErr != nil {
@@ -276,10 +279,9 @@ func TestMatchingItemIDsForEventWarningThresholds(t *testing.T) {
t.Errorf("Expected more than %d matched items, got %d",
matchedItemsWarningThreshold, len(ids))
}
expectedLog := fmt.Sprintf("Matched %d *attribute_filter_indexes items. Performance may be affected", len(ids))
expectedLog := "Matched 105 *attribute_filter_indexes items. Performance may be affected."
logContent := buf.String()
if !strings.Contains(logContent, expectedLog) {
t.Errorf("Expected warning not found in logs:\n%s", logContent)
}
utils.Logger.SetLogLevel(0)
}