Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit aff9317

Browse files
committed
Move locking to the public methods
1 parent eac5ddf commit aff9317

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

platform/stats/ingest_statistics.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ func (s *Statistics) process(index string,
8383

8484
flatJson := util.FlattenMap(jsonData, nestedSeparator)
8585

86-
mu.Lock()
87-
defer mu.Unlock()
88-
8986
statistics, ok := (*s)[index]
9087
if !ok {
9188
statistics = &IngestStatistics{IndexName: index, Keys: make(map[string]*KeyStatistics)}
@@ -121,6 +118,10 @@ func (s *Statistics) process(index string,
121118
}
122119

123120
func (s *Statistics) Process(ingestStatsEnabled bool, index string, jsonData types.JSON, nestedSeparator string) {
121+
122+
mu.Lock()
123+
defer mu.Unlock()
124+
124125
if ingestStatsEnabled {
125126
s.process(index, jsonData, false, nestedSeparator)
126127
}
@@ -130,6 +131,10 @@ func (s *Statistics) Process(ingestStatsEnabled bool, index string, jsonData typ
130131
}
131132

132133
func (s *Statistics) UpdateNonSchemaValues(ingestStatsEnabled bool, index string, jsonData types.JSON, nestedSeparator string) {
134+
135+
mu.Lock()
136+
defer mu.Unlock()
137+
133138
if ingestStatsEnabled {
134139
s.process(index, jsonData, true, nestedSeparator)
135140
}

0 commit comments

Comments
 (0)