Skip to content

Commit

Permalink
WriteCombinator now has stats on blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Moore <[email protected]>
  • Loading branch information
jimmyaxod committed Nov 26, 2024
1 parent 2115699 commit 3bc5da7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/storage/modules/write_combinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3bc5da7

Please sign in to comment.