Skip to content

Commit

Permalink
Merge branch 'dev' into pchain_merkleDB
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Laine authored Nov 29, 2023
2 parents 1161e11 + 6ed238c commit bd0e37d
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 89 deletions.
16 changes: 10 additions & 6 deletions snow/engine/snowman/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ package snowman
import (
"context"

"github.com/prometheus/client_golang/prometheus"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/utils/set"
)

// issuer issues [blk] into to consensus after its dependencies are met.
type issuer struct {
t *Transitive
blk snowman.Block
abandoned bool
deps set.Set[ids.ID]
push bool
t *Transitive
nodeID ids.NodeID // nodeID of the peer that provided this block
blk snowman.Block
issuedMetric prometheus.Counter
abandoned bool
deps set.Set[ids.ID]
push bool
}

func (i *issuer) Dependencies() set.Set[ids.ID] {
Expand Down Expand Up @@ -51,5 +55,5 @@ func (i *issuer) Update(ctx context.Context) {
return
}
// Issue the block into consensus
i.t.errs.Add(i.t.deliver(ctx, i.blk, i.push))
i.t.errs.Add(i.t.deliver(ctx, i.nodeID, i.blk, i.push, i.issuedMetric))
}
30 changes: 30 additions & 0 deletions snow/engine/snowman/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
"github.com/ava-labs/avalanchego/utils/wrappers"
)

const (
pullGossipSource = "pull_gossip"
pushGossipSource = "push_gossip"
putGossipSource = "put_gossip"
builtSource = "built"
unknownSource = "unknown"
)

type metrics struct {
bootstrapFinished prometheus.Gauge
numRequests prometheus.Gauge
Expand All @@ -27,6 +35,8 @@ type metrics struct {
numProcessingAncestorFetchesUnneeded prometheus.Counter
getAncestorsBlks metric.Averager
selectedVoteIndex metric.Averager
issuerStake metric.Averager
issued *prometheus.CounterVec
}

func (m *metrics) Initialize(namespace string, reg prometheus.Registerer) error {
Expand Down Expand Up @@ -115,6 +125,25 @@ func (m *metrics) Initialize(namespace string, reg prometheus.Registerer) error
reg,
&errs,
)
m.issuerStake = metric.NewAveragerWithErrs(
namespace,
"issuer_stake",
"stake weight of the peer who provided a block that was issued into consensus",
reg,
&errs,
)
m.issued = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Name: "blks_issued",
Help: "number of blocks that have been issued into consensus by discovery mechanism",
}, []string{"source"})

// Register the labels
m.issued.WithLabelValues(pullGossipSource)
m.issued.WithLabelValues(pushGossipSource)
m.issued.WithLabelValues(putGossipSource)
m.issued.WithLabelValues(builtSource)
m.issued.WithLabelValues(unknownSource)

errs.Add(
reg.Register(m.bootstrapFinished),
Expand All @@ -131,6 +160,7 @@ func (m *metrics) Initialize(namespace string, reg prometheus.Registerer) error
reg.Register(m.numProcessingAncestorFetchesDropped),
reg.Register(m.numProcessingAncestorFetchesSucceeded),
reg.Register(m.numProcessingAncestorFetchesUnneeded),
reg.Register(m.issued),
)
return errs.Err
}
Loading

0 comments on commit bd0e37d

Please sign in to comment.