mirror of
https://github.com/prometheus/prometheus
synced 2025-01-30 03:33:32 +00:00
Minor LevelDB watermark handling cleanups.
This commit is contained in:
parent
84741b227d
commit
7b9ee95030
@ -492,22 +492,19 @@ func (l *LevelDBMetricPersistence) refreshHighWatermarks(groups map[model.Finger
|
|||||||
|
|
||||||
mutationCount := 0
|
mutationCount := 0
|
||||||
for fingerprint, samples := range groups {
|
for fingerprint, samples := range groups {
|
||||||
key := &dto.Fingerprint{}
|
keyEncoded := coding.NewPBEncoder(fingerprint.ToDTO())
|
||||||
value := &dto.MetricHighWatermark{}
|
value := &dto.MetricHighWatermark{}
|
||||||
raw := []byte{}
|
|
||||||
newestSampleTimestamp := samples[len(samples)-1].Timestamp
|
newestSampleTimestamp := samples[len(samples)-1].Timestamp
|
||||||
keyEncoded := coding.NewPBEncoder(key)
|
|
||||||
|
|
||||||
key.Signature = proto.String(fingerprint.ToRowKey())
|
raw, err := l.MetricHighWatermarks.Get(keyEncoded)
|
||||||
raw, err = l.MetricHighWatermarks.Get(keyEncoded)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if raw != nil {
|
if raw != nil {
|
||||||
err = proto.Unmarshal(raw, value)
|
err = proto.Unmarshal(raw, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if newestSampleTimestamp.Before(time.Unix(*value.Timestamp, 0)) {
|
if newestSampleTimestamp.Before(time.Unix(*value.Timestamp, 0)) {
|
||||||
@ -521,10 +518,10 @@ func (l *LevelDBMetricPersistence) refreshHighWatermarks(groups map[model.Finger
|
|||||||
|
|
||||||
err = l.MetricHighWatermarks.Commit(batch)
|
err = l.MetricHighWatermarks.Commit(batch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err error) {
|
func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user