From 2b63ee67bbd12d65f5cf4ea66238b933240f23fa Mon Sep 17 00:00:00 2001 From: armirveliaj Date: Wed, 1 Oct 2025 08:31:59 -0400 Subject: [PATCH] Add event to warning log for matched profiles --- engine/filterhelpers.go | 3 ++- engine/z_filterhelpers_test.go | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/engine/filterhelpers.go b/engine/filterhelpers.go index 6c7e6783e..6730988b8 100644 --- a/engine/filterhelpers.go +++ b/engine/filterhelpers.go @@ -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 } diff --git a/engine/z_filterhelpers_test.go b/engine/z_filterhelpers_test.go index 7e9dbe12e..2c198feb1 100644 --- a/engine/z_filterhelpers_test.go +++ b/engine/z_filterhelpers_test.go @@ -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) }