Skip to content

Commit

Permalink
fix(metrics): fix tx broadcast investigation metrics (#1010)
Browse files Browse the repository at this point in the history
* update eth/protocols/eth/broadcast.go

* update eth/protocols/eth/handlers.go

* chore: auto version bump [bot]

---------

Co-authored-by: HAOYUatHZ <[email protected]>
  • Loading branch information
0xmountaintop and HAOYUatHZ authored Aug 28, 2024
1 parent 118a80b commit 89e9a21
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions eth/protocols/eth/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (

var (
broadcastSendTxsLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/broadcast/direct/txs", nil)
broadcastSendTxsFailGauge = metrics.NewRegisteredGauge("eth/protocols/eth/broadcast/direct/fail", nil)
broadcastSendTxsFailCounter = metrics.NewRegisteredCounter("eth/protocols/eth/broadcast/direct/fail", nil)
broadcastSendHashesLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/broadcast/direct/hashes", nil)
broadcastSendQueueLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/broadcast/direct/queue", nil)
broadcastAnnoTxsLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/broadcast/anno/txs", nil)
broadcastAnnoTxsFailGauge = metrics.NewRegisteredGauge("eth/protocols/eth/broadcast/anno/fail", nil)
broadcastAnnoTxsFailCounter = metrics.NewRegisteredCounter("eth/protocols/eth/broadcast/anno/fail", nil)
broadcastAnnoHashesLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/broadcast/anno/hashes", nil)
broadcastAnnoQueueLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/broadcast/anno/queue", nil)
)
Expand Down Expand Up @@ -109,7 +109,7 @@ func (p *Peer) broadcastTransactions() {
broadcastSendTxsLenGauge.Update(int64(len(txs)))
if err := p.SendTransactions(txs); err != nil {
log.Debug("Sending transactions", "count", len(txs), "err", err)
broadcastSendTxsFailGauge.Inc(1)
broadcastSendTxsFailCounter.Inc(1)
fail <- err
return
}
Expand Down Expand Up @@ -184,7 +184,7 @@ func (p *Peer) announceTransactions() {
broadcastAnnoTxsLenGauge.Update(int64(len(pending)))
if err := p.sendPooledTransactionHashes(pending); err != nil {
log.Debug("Sending transaction announcements", "count", len(pending), "err", err)
broadcastAnnoTxsFailGauge.Inc(1)
broadcastAnnoTxsFailCounter.Inc(1)
fail <- err
return
}
Expand Down
24 changes: 12 additions & 12 deletions eth/protocols/eth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ import (
)

var (
newPooledTxHashesFailGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/newpooledtxhashes/fail", nil)
newPooledTxHashesFailCounter = metrics.NewRegisteredCounter("eth/protocols/eth/handlers/newpooledtxhashes/fail", nil)
newPooledTxHashesLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/newpooledtxhashes/len", nil)
getPooledTxsFailGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/getpooledtxs/fail", nil)
getPooledTxsFailCounter = metrics.NewRegisteredCounter("eth/protocols/eth/handlers/getpooledtxs/fail", nil)
getPooledTxsQueryLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/getpooledtxs/query", nil)
getPooledTxsRetrievedLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/getpooledtxs/retrieved", nil)
handleTxsFailGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/handletxs/fail", nil)
handleTxsFailCounter = metrics.NewRegisteredCounter("eth/protocols/eth/handlers/handletxs/fail", nil)
handleTxsLenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/handletxs/len", nil)
handleTxsNilGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/handletxs/nil", nil)
pooledTxs66FailGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/pooledtxs66/fail", nil)
handleTxsNilCounter = metrics.NewRegisteredCounter("eth/protocols/eth/handlers/handletxs/nil", nil)
pooledTxs66FailCounter = metrics.NewRegisteredCounter("eth/protocols/eth/handlers/pooledtxs66/fail", nil)
pooledTxs66LenGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/pooledtxs66/len", nil)
pooledTxs66NillGauge = metrics.NewRegisteredGauge("eth/protocols/eth/handlers/pooledtxs66/nil", nil)
pooledTxs66NilCounter = metrics.NewRegisteredCounter("eth/protocols/eth/handlers/pooledtxs66/nil", nil)
)

// handleGetBlockHeaders66 is the eth/66 version of handleGetBlockHeaders
Expand Down Expand Up @@ -339,7 +339,7 @@ func handleNewPooledTransactionHashes(backend Backend, msg Decoder, peer *Peer)
ann := new(NewPooledTransactionHashesPacket)
if err := msg.Decode(ann); err != nil {
log.Debug("Failed to decode `NewPooledTransactionHashesPacket`", "peer", peer.String(), "err", err)
newPooledTxHashesFailGauge.Inc(1)
newPooledTxHashesFailCounter.Inc(1)
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
}
// Schedule all the unknown hashes for retrieval
Expand All @@ -356,7 +356,7 @@ func handleGetPooledTransactions66(backend Backend, msg Decoder, peer *Peer) err
var query GetPooledTransactionsPacket66
if err := msg.Decode(&query); err != nil {
log.Debug("Failed to decode `GetPooledTransactionsPacket66`", "peer", peer.String(), "err", err)
getPooledTxsFailGauge.Inc(1)
getPooledTxsFailCounter.Inc(1)
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
}
hashes, txs := answerGetPooledTransactions(backend, query.GetPooledTransactionsPacket, peer)
Expand Down Expand Up @@ -402,7 +402,7 @@ func handleTransactions(backend Backend, msg Decoder, peer *Peer) error {
// Transactions can be processed, parse all of them and deliver to the pool
var txs TransactionsPacket
if err := msg.Decode(&txs); err != nil {
handleTxsFailGauge.Inc(1)
handleTxsFailCounter.Inc(1)
log.Debug("Failed to decode `TransactionsPacket`", "peer", peer.String(), "err", err)
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
}
Expand All @@ -411,7 +411,7 @@ func handleTransactions(backend Backend, msg Decoder, peer *Peer) error {
for i, tx := range txs {
// Validate and mark the remote transaction
if tx == nil {
handleTxsNilGauge.Inc(1)
handleTxsNilCounter.Inc(1)
log.Debug("handleTransactions: transaction is nil", "peer", peer.String(), "i", i)
return fmt.Errorf("%w: transaction %d is nil", errDecode, i)
}
Expand All @@ -428,7 +428,7 @@ func handlePooledTransactions66(backend Backend, msg Decoder, peer *Peer) error
// Transactions can be processed, parse all of them and deliver to the pool
var txs PooledTransactionsPacket66
if err := msg.Decode(&txs); err != nil {
pooledTxs66FailGauge.Inc(1)
pooledTxs66FailCounter.Inc(1)
log.Debug("Failed to decode `PooledTransactionsPacket66`", "peer", peer.String(), "err", err)
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
}
Expand All @@ -437,7 +437,7 @@ func handlePooledTransactions66(backend Backend, msg Decoder, peer *Peer) error
for i, tx := range txs.PooledTransactionsPacket {
// Validate and mark the remote transaction
if tx == nil {
pooledTxs66NillGauge.Inc(1)
pooledTxs66NilCounter.Inc(1)
log.Debug("handlePooledTransactions: transaction is nil", "peer", peer.String(), "i", i)
return fmt.Errorf("%w: transaction %d is nil", errDecode, i)
}
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
VersionMajor = 5 // Major version component of the current release
VersionMinor = 7 // Minor version component of the current release
VersionPatch = 3 // Patch version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string
)

Expand Down

0 comments on commit 89e9a21

Please sign in to comment.