mirror of https://github.com/prometheus/prometheus
Simplify AppendSamples by allowing it to be goroutine-unsafe.
parent
8a1c195b54
commit
fe518fdb28
|
@ -24,7 +24,7 @@ import (
|
|||
)
|
||||
|
||||
// Storage ingests and manages samples, along with various indexes. All methods
|
||||
// are goroutine-safe.
|
||||
// except AppendSamples are goroutine-safe.
|
||||
type Storage interface {
|
||||
prometheus.Collector
|
||||
// AppendSamples stores a group of new samples. Multiple samples for the
|
||||
|
@ -32,7 +32,7 @@ type Storage interface {
|
|||
// oldest to newest (both in the same call to AppendSamples and across
|
||||
// multiple calls). When AppendSamples has returned, the appended
|
||||
// samples might not be queryable immediately. (Use WaitForIndexing to
|
||||
// wait for complete processing.)
|
||||
// wait for complete processing.) This method is not goroutine-safe.
|
||||
AppendSamples(clientmodel.Samples)
|
||||
// NewPreloader returns a new Preloader which allows preloading and pinning
|
||||
// series data into memory for use within a query.
|
||||
|
|
|
@ -73,7 +73,6 @@ type memorySeriesStorage struct {
|
|||
lastTimestampAppended clientmodel.Timestamp
|
||||
// Wait group for goroutines appending samples with the same timestamp.
|
||||
appendWaitGroup sync.WaitGroup
|
||||
appendMtx sync.Mutex
|
||||
|
||||
persistQueue chan persistRequest
|
||||
persistStopped chan struct{}
|
||||
|
@ -371,13 +370,6 @@ func (s *memorySeriesStorage) GetMetricForFingerprint(fp clientmodel.Fingerprint
|
|||
|
||||
// AppendSamples implements Storage.
|
||||
func (s *memorySeriesStorage) AppendSamples(samples clientmodel.Samples) {
|
||||
if len(samples) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
s.appendMtx.Lock()
|
||||
defer s.appendMtx.Unlock()
|
||||
|
||||
for _, sample := range samples {
|
||||
if sample.Timestamp != s.lastTimestampAppended {
|
||||
// Timestamp has changed. We have to wait for all
|
||||
|
@ -392,7 +384,6 @@ func (s *memorySeriesStorage) AppendSamples(samples clientmodel.Samples) {
|
|||
s.appendWaitGroup.Done()
|
||||
}(sample)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *memorySeriesStorage) appendSample(sample *clientmodel.Sample) {
|
||||
|
|
Loading…
Reference in New Issue