From a1087ed37a56491e36266e9bb619a9707d5b0000 Mon Sep 17 00:00:00 2001 From: Ganesh Vernekar <15064823+codesome@users.noreply.github.com> Date: Thu, 1 Jul 2021 18:19:04 +0530 Subject: [PATCH] Fix scraping of sparse histograms (#9031) Signed-off-by: Ganesh Vernekar --- storage/remote/write.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/storage/remote/write.go b/storage/remote/write.go index 7d8f57d96..5eab6e919 100644 --- a/storage/remote/write.go +++ b/storage/remote/write.go @@ -15,7 +15,6 @@ package remote import ( "context" - "errors" "fmt" "sync" "time" @@ -220,6 +219,7 @@ type timestampTracker struct { writeStorage *WriteStorage samples int64 exemplars int64 + histograms int64 highestTimestamp int64 highestRecvTimestamp *maxTimestamp } @@ -238,8 +238,12 @@ func (t *timestampTracker) AppendExemplar(_ uint64, _ labels.Labels, _ exemplar. return 0, nil } -func (t *timestampTracker) AppendHistogram(_ uint64, _ labels.Labels, _ int64, _ histogram.SparseHistogram) (uint64, error) { - return 0, errors.New("not implemented") +func (t *timestampTracker) AppendHistogram(_ uint64, _ labels.Labels, ts int64, _ histogram.SparseHistogram) (uint64, error) { + t.histograms++ + if ts > t.highestTimestamp { + t.highestTimestamp = ts + } + return 0, nil } // Commit implements storage.Appender.