mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
chore: add metrics for slow peer
This commit is contained in:
parent
0ec63272bf
commit
843333afa6
1 changed files with 18 additions and 0 deletions
|
|
@ -107,6 +107,15 @@ var (
|
||||||
txFetcherQueueingHashes = metrics.NewRegisteredGauge("eth/fetcher/transaction/queueing/hashes", nil)
|
txFetcherQueueingHashes = metrics.NewRegisteredGauge("eth/fetcher/transaction/queueing/hashes", nil)
|
||||||
txFetcherFetchingPeers = metrics.NewRegisteredGauge("eth/fetcher/transaction/fetching/peers", nil)
|
txFetcherFetchingPeers = metrics.NewRegisteredGauge("eth/fetcher/transaction/fetching/peers", nil)
|
||||||
txFetcherFetchingHashes = metrics.NewRegisteredGauge("eth/fetcher/transaction/fetching/hashes", nil)
|
txFetcherFetchingHashes = metrics.NewRegisteredGauge("eth/fetcher/transaction/fetching/hashes", nil)
|
||||||
|
|
||||||
|
txFetcherSlowPeers = metrics.NewRegisteredGauge("eth/fetcher/transaction/slow/peers", nil)
|
||||||
|
// Note: this metric does not mean that the fetching of a transaction
|
||||||
|
// was blocked by a specific peer during this period, since we request
|
||||||
|
// another peer to fetch the same transaction hash.
|
||||||
|
// The purpose of this metric is to measure how long it takes for a slow peer
|
||||||
|
// to become "unfrozen", either by eventually replying to the request
|
||||||
|
// or by being dropped, measuring from the moment the request was sent.
|
||||||
|
txFetcherSlowWait = metrics.NewRegisteredHistogram("eth/fetcher/transaction/slow/wait", nil, metrics.NewExpDecaySample(1028, 0.015))
|
||||||
)
|
)
|
||||||
|
|
||||||
var errTerminated = errors.New("terminated")
|
var errTerminated = errors.New("terminated")
|
||||||
|
|
@ -635,6 +644,7 @@ func (f *TxFetcher) loop() {
|
||||||
}
|
}
|
||||||
// Keep track of the request as dangling, but never expire
|
// Keep track of the request as dangling, but never expire
|
||||||
f.requests[peer].hashes = nil
|
f.requests[peer].hashes = nil
|
||||||
|
txFetcherSlowPeers.Inc(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Schedule a new transaction retrieval
|
// Schedule a new transaction retrieval
|
||||||
|
|
@ -728,6 +738,10 @@ func (f *TxFetcher) loop() {
|
||||||
log.Warn("Unexpected transaction delivery", "peer", delivery.origin)
|
log.Warn("Unexpected transaction delivery", "peer", delivery.origin)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if req.hashes == nil {
|
||||||
|
txFetcherSlowPeers.Dec(1)
|
||||||
|
txFetcherSlowWait.Update(time.Duration(f.clock.Now() - req.time).Nanoseconds())
|
||||||
|
}
|
||||||
delete(f.requests, delivery.origin)
|
delete(f.requests, delivery.origin)
|
||||||
|
|
||||||
// Anything not delivered should be re-scheduled (with or without
|
// Anything not delivered should be re-scheduled (with or without
|
||||||
|
|
@ -807,6 +821,10 @@ func (f *TxFetcher) loop() {
|
||||||
}
|
}
|
||||||
delete(f.fetching, hash)
|
delete(f.fetching, hash)
|
||||||
}
|
}
|
||||||
|
if request.hashes == nil {
|
||||||
|
txFetcherSlowPeers.Dec(1)
|
||||||
|
txFetcherSlowWait.Update(time.Duration(f.clock.Now() - request.time).Nanoseconds())
|
||||||
|
}
|
||||||
delete(f.requests, drop.peer)
|
delete(f.requests, drop.peer)
|
||||||
}
|
}
|
||||||
// Clean up general announcement tracking
|
// Clean up general announcement tracking
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue