diff --git a/storage/metric/interface.go b/storage/metric/interface.go index 5da0e967f..1bdcece9f 100644 --- a/storage/metric/interface.go +++ b/storage/metric/interface.go @@ -28,7 +28,10 @@ type Persistence interface { // closed when finished. Close() - // Record a group of new samples in the storage layer. + // Record a group of new samples in the storage layer. Multiple samples for + // the same fingerprint need to be submitted in chronological order, from + // oldest to newest (both in the same call to AppendSamples and across + // multiple calls). AppendSamples(clientmodel.Samples) error // Get all of the metric fingerprints that are associated with the diff --git a/storage/metric/tiered/leveldb.go b/storage/metric/tiered/leveldb.go index 5c46789ad..3b15bdd2a 100644 --- a/storage/metric/tiered/leveldb.go +++ b/storage/metric/tiered/leveldb.go @@ -16,7 +16,6 @@ package tiered import ( "flag" "fmt" - "sort" "sync" "time" @@ -258,9 +257,8 @@ func (l *LevelDBPersistence) AppendSample(sample *clientmodel.Sample) (err error return } -// groupByFingerprint collects all of the provided samples, groups them -// together by their respective metric fingerprint, and finally sorts -// them chronologically. +// groupByFingerprint collects all of the provided samples and groups them +// together by their respective metric fingerprint. func groupByFingerprint(samples clientmodel.Samples) map[clientmodel.Fingerprint]clientmodel.Samples { fingerprintToSamples := map[clientmodel.Fingerprint]clientmodel.Samples{} @@ -272,23 +270,6 @@ func groupByFingerprint(samples clientmodel.Samples) map[clientmodel.Fingerprint fingerprintToSamples[*fingerprint] = samples } - sortingSemaphore := make(chan bool, sortConcurrency) - doneSorting := sync.WaitGroup{} - - for _, samples := range fingerprintToSamples { - doneSorting.Add(1) - - sortingSemaphore <- true - go func(samples clientmodel.Samples) { - sort.Sort(samples) - - <-sortingSemaphore - doneSorting.Done() - }(samples) - } - - doneSorting.Wait() - return fingerprintToSamples }