add type to duplicate metric

This commit is contained in:
William Banfield
2022-11-23 10:38:48 -05:00
parent adfec78fff
commit 8ebe9163f9
3 changed files with 6 additions and 2 deletions

View File

@@ -258,7 +258,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
Subsystem: MetricsSubsystem,
Name: "duplicate_vote_receive",
Help: "Number of votes received multiple times from the same peer by peer",
}, append(labels, "peer_id")).With(labelsAndValues...),
}, append(labels, "peer_id", "type")).With(labelsAndValues...),
}
}

View File

@@ -351,7 +351,7 @@ func (conR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
duplicate := ps.SetReceivedVote(msg.Vote)
if duplicate {
conR.Metrics.DuplicateVoteReceive.With("peer_id", string(e.Src.ID())).Add(1)
conR.Metrics.DuplicateVoteReceive.With("peer_id", string(e.Src.ID()), "type", msg.Vote.Type.String()).Add(1)
}
cs.peerMsgQueue <- msgInfo{msg, e.Src.ID()}

View File

@@ -19,6 +19,8 @@ type BitArray struct {
Elems []uint64 `json:"elems"` // NOTE: persisted via reflect, must be exported
}
// New bit array creates a bit array where all of the bits are initially 'false'
//
// NewBitArray returns a new bit array.
// It returns nil if the number of bits is zero.
func NewBitArray(bits int) *BitArray {
@@ -39,6 +41,8 @@ func (bA *BitArray) Size() int {
return bA.Bits
}
// The bit array represents true as 1 and false as 0
//
// GetIndex returns the bit at index i within the bit array.
// The behavior is undefined if i >= bA.Bits
func (bA *BitArray) GetIndex(i int) bool {