aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/network/depo.go
diff options
context:
space:
mode:
authorAnton Evangelatov <anton.evangelatov@gmail.com>2018-02-23 21:19:59 +0800
committerBalint Gabor <balint.g@gmail.com>2018-02-23 21:19:59 +0800
commitdcca613a0b4c6ce56e52f4607cf71f4f1338db8f (patch)
tree298e858e042df9d515aa091a79902ee9bf6d9f7b /swarm/network/depo.go
parentb677a07d36c957c4221bae952189559ac0c70537 (diff)
downloadgo-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar
go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.gz
go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.bz2
go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.lz
go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.xz
go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.zst
go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.zip
swarm: initial instrumentation (#15969)
* swarm: initial instrumentation with go-metrics * swarm: initialise metrics collection and add ResettingTimer to HTTP requests * swarm: update metrics flags names. remove redundant Timer. * swarm: rename method for periodically updating gauges * swarm: finalise metrics after feedback * swarm/network: always init kad metrics containers * swarm/network: off-by-one index in metrics containers * swarm, metrics: resolved conflicts
Diffstat (limited to 'swarm/network/depo.go')
-rw-r--r--swarm/network/depo.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/swarm/network/depo.go b/swarm/network/depo.go
index 17540d2f9..5ffbf8be1 100644
--- a/swarm/network/depo.go
+++ b/swarm/network/depo.go
@@ -23,9 +23,19 @@ import (
"time"
"github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/swarm/storage"
)
+//metrics variables
+var (
+ syncReceiveCount = metrics.NewRegisteredCounter("network.sync.recv.count", nil)
+ syncReceiveIgnore = metrics.NewRegisteredCounter("network.sync.recv.ignore", nil)
+ syncSendCount = metrics.NewRegisteredCounter("network.sync.send.count", nil)
+ syncSendRefused = metrics.NewRegisteredCounter("network.sync.send.refused", nil)
+ syncSendNotFound = metrics.NewRegisteredCounter("network.sync.send.notfound", nil)
+)
+
// Handler for storage/retrieval related protocol requests
// implements the StorageHandler interface used by the bzz protocol
type Depo struct {
@@ -107,6 +117,7 @@ func (self *Depo) HandleStoreRequestMsg(req *storeRequestMsgData, p *peer) {
log.Trace(fmt.Sprintf("Depo.handleStoreRequest: %v not found locally. create new chunk/request", req.Key))
// not found in memory cache, ie., a genuine store request
// create chunk
+ syncReceiveCount.Inc(1)
chunk = storage.NewChunk(req.Key, nil)
case chunk.SData == nil:
@@ -116,6 +127,7 @@ func (self *Depo) HandleStoreRequestMsg(req *storeRequestMsgData, p *peer) {
default:
// data is found, store request ignored
// this should update access count?
+ syncReceiveIgnore.Inc(1)
log.Trace(fmt.Sprintf("Depo.HandleStoreRequest: %v found locally. ignore.", req))
islocal = true
//return
@@ -172,11 +184,14 @@ func (self *Depo) HandleRetrieveRequestMsg(req *retrieveRequestMsgData, p *peer)
SData: chunk.SData,
requestTimeout: req.timeout, //
}
+ syncSendCount.Inc(1)
p.syncer.addRequest(sreq, DeliverReq)
} else {
+ syncSendRefused.Inc(1)
log.Trace(fmt.Sprintf("Depo.HandleRetrieveRequest: %v - content found, not wanted", req.Key.Log()))
}
} else {
+ syncSendNotFound.Inc(1)
log.Trace(fmt.Sprintf("Depo.HandleRetrieveRequest: %v - content not found locally. asked swarm for help. will get back", req.Key.Log()))
}
}