Skip to content

Commit 61a20f3

Browse files
Miya Chentailingchen
authored andcommitted
core: add some metrics for tx pool and blockchain
1 parent 6e35550 commit 61a20f3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

core/blockchain.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ import (
4747

4848
var (
4949
blockInsertTimer = metrics.NewTimer("chain/inserts")
50+
txInsertCounter = metrics.NewCounter("chain/tx/inserts")
51+
txInsertMeter = metrics.NewMeter("chain/tx/insert_rate")
52+
forkBlockCounter = metrics.NewCounter("chain/forkblocks")
5053

5154
ErrNoGenesis = errors.New("Genesis not found in chain")
5255
)
@@ -852,9 +855,12 @@ func (bc *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err er
852855
status = CanonStatTy
853856
} else {
854857
status = SideStatTy
858+
forkBlockCounter.Inc(1)
855859
}
856860

857861
bc.futureBlocks.Remove(block.Hash())
862+
txInsertCounter.Inc(int64(len(block.Transactions())))
863+
txInsertMeter.Mark(int64(len(block.Transactions())))
858864

859865
return
860866
}

eth/api_backend.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ import (
3131
"github.com/ethereum/go-ethereum/eth/gasprice"
3232
"github.com/ethereum/go-ethereum/ethdb"
3333
"github.com/ethereum/go-ethereum/event"
34+
"github.com/ethereum/go-ethereum/metrics"
3435
"github.com/ethereum/go-ethereum/params"
3536
"github.com/ethereum/go-ethereum/rpc"
3637
)
3738

39+
var (
40+
txSendCounter = metrics.NewCounter("api/txsend")
41+
)
42+
3843
// EthApiBackend implements ethapi.Backend for full nodes
3944
type EthApiBackend struct {
4045
eth *Ethereum
@@ -116,6 +121,7 @@ func (b *EthApiBackend) GetEVM(ctx context.Context, msg core.Message, state *sta
116121
}
117122

118123
func (b *EthApiBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error {
124+
txSendCounter.Inc(1)
119125
return b.eth.txPool.AddLocal(signedTx)
120126
}
121127

0 commit comments

Comments
 (0)