Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions platform/stats/ingest_statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ func (s *Statistics) process(index string,

flatJson := util.FlattenMap(jsonData, nestedSeparator)

mu.Lock()
defer mu.Unlock()

statistics, ok := (*s)[index]
if !ok {
statistics = &IngestStatistics{IndexName: index, Keys: make(map[string]*KeyStatistics)}
Expand Down Expand Up @@ -121,6 +118,10 @@ func (s *Statistics) process(index string,
}

func (s *Statistics) Process(ingestStatsEnabled bool, index string, jsonData types.JSON, nestedSeparator string) {

mu.Lock()
Copy link

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider narrowing the scope of the mutex lock to only cover the critical map access operations to reduce potential contention if the process function performs heavy processing.

Copilot uses AI. Check for mistakes.
defer mu.Unlock()

if ingestStatsEnabled {
s.process(index, jsonData, false, nestedSeparator)
}
Expand All @@ -130,6 +131,10 @@ func (s *Statistics) Process(ingestStatsEnabled bool, index string, jsonData typ
}

func (s *Statistics) UpdateNonSchemaValues(ingestStatsEnabled bool, index string, jsonData types.JSON, nestedSeparator string) {

mu.Lock()
defer mu.Unlock()

if ingestStatsEnabled {
s.process(index, jsonData, true, nestedSeparator)
}
Expand Down
Loading