Skip to content

Commit

Permalink
measure block sorter queue size
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaidashenko committed Feb 10, 2025
1 parent 96c326d commit ab61cd2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/solana/logpoller/blocks_sorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ import (
"context"
"sync"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services"
)

const blocksChBuffer = 16

var promPoolRPCNodeHighestSeenBlock = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "block_sorter_queue",
Help: "The highest seen block for the given RPC node",
}, []string{})

type blocksSorter struct {
// service state management
services.Service
Expand Down Expand Up @@ -69,6 +77,7 @@ func (p *blocksSorter) readBlocks(ctx context.Context) {
}

p.mu.Lock()
promPoolRPCNodeHighestSeenBlock.WithLabelValues().Set(float64(len(p.readyBlocks)))
p.readyBlocks[block.SlotNumber] = block
p.mu.Unlock()
// try leaving a msg that new block is ready
Expand Down Expand Up @@ -110,6 +119,7 @@ func (p *blocksSorter) readNextReadyBlock() *Block {

slotNumber := element.Value.(uint64)
block, ok := p.readyBlocks[slotNumber]
promPoolRPCNodeHighestSeenBlock.WithLabelValues().Set(float64(len(p.readyBlocks)))
if !ok {
return nil
}
Expand Down

0 comments on commit ab61cd2

Please sign in to comment.