Skip to content

Commit 050c0a3

Browse files
committed
refactor(soc-ai): rename queue functions to use consistent casing and improve logging format
1 parent e4acc56 commit 050c0a3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

plugins/soc-ai/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func main() {
1515
go config.StartConfigurationSystem()
1616

1717
time.Sleep(2 * time.Second)
18-
InitializeQueue()
18+
initializeQueue()
1919

2020
err := plugins.InitCorrelationPlugin("com.utmstack.soc-ai", correlate)
2121
if err != nil {
@@ -43,7 +43,7 @@ func correlate(_ context.Context,
4343
return &emptypb.Empty{}, nil
4444
}
4545

46-
if !EnqueueAlert(alert) {
46+
if !enqueueAlert(alert) {
4747
return &emptypb.Empty{}, nil
4848
}
4949

plugins/soc-ai/queue.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const (
4848
QueueFullTimeout = 100 * time.Millisecond
4949
)
5050

51-
func InitializeQueue() {
51+
func initializeQueue() {
5252
ctx, cancel := context.WithCancel(context.Background())
5353

5454
alertQueue = &AlertQueue{
@@ -67,7 +67,7 @@ func InitializeQueue() {
6767

6868
}
6969

70-
func EnqueueAlert(alert *plugins.Alert) bool {
70+
func enqueueAlert(alert *plugins.Alert) bool {
7171
if alertQueue == nil {
7272
return false
7373
}
@@ -97,10 +97,6 @@ func EnqueueAlert(alert *plugins.Alert) bool {
9797
"total_dropped": totalDropped,
9898
"consecutive_drops": consecutiveDrops,
9999
})
100-
catcher.Error(fmt.Sprintf("QUEUE FULL - Alert %s DROPPED! Queue size: %d/%d, Total dropped: %d, Consecutive: %d.",
101-
alert.Id, currentQueueSize, DefaultQueueSize, totalDropped, consecutiveDrops),
102-
nil, map[string]any{"process": "plugin_com.utmstack.soc-ai"},
103-
)
104100

105101
elastic.RegisterError(fmt.Sprintf("Alert dropped - Queue FULL (%d/%d)", currentQueueSize, DefaultQueueSize), alert.Id)
106102
alertQueue.lastDropAlert = time.Now()
@@ -187,8 +183,13 @@ func (aq *AlertQueue) metricsLogger() {
187183
errors := atomic.LoadInt64(&aq.errorCount)
188184
queueSize := atomic.LoadInt64(&aq.queueSize)
189185

190-
catcher.Info(fmt.Sprintf("Queue metrics - Processed: %d, Dropped: %d, Errors: %d, Current queue size: %d",
191-
processed, dropped, errors, queueSize), map[string]any{"process": "plugin_com.utmstack.soc-ai"})
186+
catcher.Info("SOC-AI queue metrics", map[string]any{
187+
"process": "plugin_com.utmstack.soc-ai",
188+
"processed": processed,
189+
"dropped": dropped,
190+
"errors": errors,
191+
"queueSize": queueSize,
192+
})
192193
}
193194
}
194195
}

0 commit comments

Comments
 (0)