diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-06-22 01:23:51 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-06-24 23:34:04 +0800 |
commit | b426301467304a6c047df9baa033a042ddf3c4bb (patch) | |
tree | 401e9a24925316d40f646af3bea13a8f63c36823 /eth/fetcher | |
parent | 6994a3daaa0acfc8431e33da535c85e23ab319e0 (diff) | |
download | dexon-b426301467304a6c047df9baa033a042ddf3c4bb.tar.gz dexon-b426301467304a6c047df9baa033a042ddf3c4bb.tar.zst dexon-b426301467304a6c047df9baa033a042ddf3c4bb.zip |
cmd/geth, eth/fetcher: polish metrics reporting, add some more
Diffstat (limited to 'eth/fetcher')
-rw-r--r-- | eth/fetcher/fetcher.go | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/eth/fetcher/fetcher.go b/eth/fetcher/fetcher.go index a9f4227c4..a8f0dddbd 100644 --- a/eth/fetcher/fetcher.go +++ b/eth/fetcher/fetcher.go @@ -7,12 +7,11 @@ import ( "math/rand" "time" - "github.com/rcrowley/go-metrics" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" + "github.com/rcrowley/go-metrics" "gopkg.in/karalabe/cookiejar.v2/collections/prque" ) @@ -100,9 +99,11 @@ type Fetcher struct { importedHook func(*types.Block) // Method to call upon successful block import // Runtime metrics - announceStats metrics.Meter - broadcastStats metrics.Meter - discardStats metrics.Meter + announceMeter metrics.Meter // Counter for metering the inbound announcements + announceTimer metrics.Timer // Counter and timer for metering the announce forwarding + broadcastMeter metrics.Meter // Counter for metering the inbound propagations + broadcastTimer metrics.Timer // Counter and timer for metering the block forwarding + discardMeter metrics.Meter // Counter for metering the discarded blocks } // New creates a block fetcher to retrieve blocks based on hash announcements. @@ -125,9 +126,11 @@ func New(getBlock blockRetrievalFn, validateBlock blockValidatorFn, broadcastBlo chainHeight: chainHeight, insertChain: insertChain, dropPeer: dropPeer, - announceStats: metrics.GetOrRegisterMeter("eth/Announced Blocks", metrics.DefaultRegistry), - broadcastStats: metrics.GetOrRegisterMeter("eth/Propagated Blocks", metrics.DefaultRegistry), - discardStats: metrics.GetOrRegisterMeter("eth/Discarded Blocks", metrics.DefaultRegistry), + announceMeter: metrics.GetOrRegisterMeter("eth/RemoteAnnounces", metrics.DefaultRegistry), + announceTimer: metrics.GetOrRegisterTimer("eth/LocalAnnounces", metrics.DefaultRegistry), + broadcastMeter: metrics.GetOrRegisterMeter("eth/RemoteBroadcasts", metrics.DefaultRegistry), + broadcastTimer: metrics.GetOrRegisterTimer("eth/LocalBroadcasts", metrics.DefaultRegistry), + discardMeter: metrics.GetOrRegisterMeter("eth/DiscardedBlocks", metrics.DefaultRegistry), } } @@ -239,7 +242,7 @@ func (f *Fetcher) loop() { case notification := <-f.notify: // A block was announced, make sure the peer isn't DOSing us - f.announceStats.Mark(1) + f.announceMeter.Mark(1) count := f.announces[notification.origin] + 1 if count > hashLimit { @@ -258,7 +261,7 @@ func (f *Fetcher) loop() { case op := <-f.inject: // A direct block insertion was requested, try and fill any pending gaps - f.broadcastStats.Mark(1) + f.broadcastMeter.Mark(1) f.enqueue(op.origin, op.block) case hash := <-f.done: @@ -418,6 +421,7 @@ func (f *Fetcher) insert(peer string, block *types.Block) { f.dropPeer(peer) return } + f.broadcastTimer.UpdateSince(block.ReceivedAt) go f.broadcastBlock(block, true) // Run the actual import and log any issues @@ -426,6 +430,7 @@ func (f *Fetcher) insert(peer string, block *types.Block) { return } // If import succeeded, broadcast the block + f.announceTimer.UpdateSince(block.ReceivedAt) go f.broadcastBlock(block, false) // Invoke the testing hook if needed |