Skip to content

Commit

Permalink
core: add some metrics for tx pool and blockchain
Browse files Browse the repository at this point in the history
  • Loading branch information
Miya Chen authored and tailingchen committed Aug 1, 2017
1 parent 6e35550 commit 61a20f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ import (

var (
blockInsertTimer = metrics.NewTimer("chain/inserts")
txInsertCounter = metrics.NewCounter("chain/tx/inserts")
txInsertMeter = metrics.NewMeter("chain/tx/insert_rate")
forkBlockCounter = metrics.NewCounter("chain/forkblocks")

ErrNoGenesis = errors.New("Genesis not found in chain")
)
Expand Down Expand Up @@ -852,9 +855,12 @@ func (bc *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err er
status = CanonStatTy
} else {
status = SideStatTy
forkBlockCounter.Inc(1)
}

bc.futureBlocks.Remove(block.Hash())
txInsertCounter.Inc(int64(len(block.Transactions())))
txInsertMeter.Mark(int64(len(block.Transactions())))

return
}
Expand Down
6 changes: 6 additions & 0 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ import (
"github.com/ethereum/go-ethereum/eth/gasprice"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
)

var (
txSendCounter = metrics.NewCounter("api/txsend")
)

// EthApiBackend implements ethapi.Backend for full nodes
type EthApiBackend struct {
eth *Ethereum
Expand Down Expand Up @@ -116,6 +121,7 @@ func (b *EthApiBackend) GetEVM(ctx context.Context, msg core.Message, state *sta
}

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

Expand Down

0 comments on commit 61a20f3

Please sign in to comment.