From a9614734228bf13cf8781060f6ddc0ccf847c4e8 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Wed, 24 May 2017 20:10:52 -0600 Subject: [PATCH] Add statsd gauges for row count. --- fragment.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fragment.go b/fragment.go index 8c0964da1..bf29cae03 100644 --- a/fragment.go +++ b/fragment.go @@ -86,6 +86,9 @@ type Fragment struct { cache Cache CacheSize uint32 + // Stats reporting. + maxRowID uint64 + // Cache containing full rows (not just counts). rowCache BitmapCache @@ -166,6 +169,11 @@ func (f *Fragment) Open() error { // Clear checksums. f.checksums = make(map[int][]byte) + // Read last bit to determine max row. + pos := f.storage.Max() + f.maxRowID = pos / SliceWidth + f.stats.Gauge("rows", float64(f.maxRowID)) + return nil }(); err != nil { f.close() @@ -409,6 +417,12 @@ func (f *Fragment) setBit(rowID, columnID uint64) (changed bool, err error) { f.stats.Count("setN", 1) + // Update row count if they have increased. + if rowID > f.maxRowID { + f.maxRowID = rowID + f.stats.Gauge("rows", float64(f.maxRowID)) + } + return changed, nil }