From 3bc5da7ad862368f358f4f38defd365b0667b1a4 Mon Sep 17 00:00:00 2001 From: Jimmy Moore Date: Tue, 26 Nov 2024 12:25:30 +0000 Subject: [PATCH] WriteCombinator now has stats on blocks Signed-off-by: Jimmy Moore --- pkg/storage/modules/write_combinator.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/storage/modules/write_combinator.go b/pkg/storage/modules/write_combinator.go index d75b2fe..69048a0 100644 --- a/pkg/storage/modules/write_combinator.go +++ b/pkg/storage/modules/write_combinator.go @@ -35,20 +35,25 @@ func NewWriteCombinator(prov storage.Provider, blockSize int) *WriteCombinator { } type WriteCombinatorMetrics struct { - WritesAllowed map[int]uint64 - WritesBlocked map[int]uint64 + WritesAllowed map[int]uint64 + WritesBlocked map[int]uint64 + AvailableBlocks map[int][]uint + NumBlocks int } func (i *WriteCombinator) GetMetrics() *WriteCombinatorMetrics { wcm := &WriteCombinatorMetrics{ - WritesAllowed: make(map[int]uint64, 0), - WritesBlocked: make(map[int]uint64, 0), + WritesAllowed: make(map[int]uint64, 0), + WritesBlocked: make(map[int]uint64, 0), + NumBlocks: i.numBlocks, + AvailableBlocks: make(map[int][]uint, 0), } i.writeLock.Lock() defer i.writeLock.Unlock() for priority, s := range i.sources { wcm.WritesAllowed[priority] = atomic.LoadUint64(&s.metricWritesAllowed) wcm.WritesBlocked[priority] = atomic.LoadUint64(&s.metricWritesBlocked) + wcm.AvailableBlocks[priority] = s.available.Collect(0, s.available.Length()) } return wcm }