Skip to content

Commit 97c8434

Browse files
committed
refactor(events): remove unused meter initialization in Analyze and startQueue functions
1 parent 6f26f08 commit 97c8434

3 files changed

Lines changed: 3 additions & 27 deletions

File tree

plugins/events/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ func main() {
118118
}
119119

120120
func (p *analysisServer) Analyze(event *plugins.Event, _ grpc.ServerStreamingServer[plugins.Alert]) error {
121-
m := utils.NewMeter("Enqueue log for OpenSearch")
122-
defer m.Elapsed("finished")
123-
124121
jLog, err := utils.ToString(event)
125122
if err != nil {
126123
return catcher.Error("cannot convert event to json", err, nil)

plugins/events/queue.go

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"github.com/threatwinds/go-sdk/catcher"
7-
"github.com/threatwinds/go-sdk/plugins"
8-
"github.com/threatwinds/go-sdk/utils"
96
"runtime"
107
"sync"
118
"time"
129

10+
"github.com/threatwinds/go-sdk/catcher"
11+
"github.com/threatwinds/go-sdk/plugins"
12+
1313
"github.com/threatwinds/go-sdk/opensearch"
1414
"github.com/tidwall/gjson"
1515
)
@@ -60,16 +60,6 @@ func startQueue() {
6060
numCPU := runtime.NumCPU() * 2
6161
for i := 0; i < numCPU; i++ {
6262
go func() {
63-
ndM := utils.NewMeter("NDJson", utils.MeterOptions{
64-
LogSlow: true,
65-
SlowThreshold: 20 * time.Millisecond,
66-
})
67-
68-
bulkM := utils.NewMeter("Bulk", utils.MeterOptions{
69-
LogSlow: true,
70-
SlowThreshold: 1 * time.Second,
71-
})
72-
7363
var ndMutex = &sync.Mutex{}
7464
var nd = make([]opensearch.BulkItem, 0, 10)
7565

@@ -81,7 +71,6 @@ func startQueue() {
8171
}
8272

8373
ndMutex.Lock()
84-
bulkM.Reset()
8574

8675
err := opensearch.Bulk(context.Background(), nd)
8776
if err != nil {
@@ -91,23 +80,17 @@ func startQueue() {
9180
nd = make([]opensearch.BulkItem, 0, 10)
9281

9382
ndMutex.Unlock()
94-
bulkM.Elapsed("bulk sent")
9583
}
9684
}()
9785

9886
for {
9987
l := <-logs
10088

101-
ndM.Reset()
102-
10389
dataType := gjson.Get(l, "dataType").String()
10490
id := gjson.Get(l, "id").String()
10591
index := opensearch.BuildCurrentIndex("v11", "log", dataType)
10692

107-
ndM.Elapsed("get index and id")
108-
10993
ndMutex.Lock()
110-
ndM.Reset()
11194

11295
nd = append(nd, opensearch.BulkItem{
11396
Index: index,
@@ -117,7 +100,6 @@ func startQueue() {
117100
})
118101

119102
ndMutex.Unlock()
120-
ndM.Elapsed("append to NDJson list")
121103
}
122104
}()
123105
}

plugins/geolocation/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ func main() {
122122
}
123123

124124
func (p *parsingServer) ParseLog(_ context.Context, transform *plugins.Transform) (*plugins.Draft, error) {
125-
m := utils.NewMeter("ParseLog")
126-
defer m.Elapsed("finished")
127-
128125
source, ok := transform.Step.Dynamic.Params["source"]
129126
if !ok {
130127
return transform.Draft, catcher.Error("'source' parameter required", nil, nil)

0 commit comments

Comments
 (0)