swarm/network: measure addPeer and deletePeer to know if Kad rearranged
swarm/storage: remove traces for put/get/set (#1389) * swarm/storage: remove traces for put/get/set * swarm/storage: remove Has traces
This commit is contained in:
parent
84dfaea246
commit
297fa1855c
@ -39,7 +39,7 @@ func NewTestSwarmServer(t *testing.T, serverFunc func(*api.API) TestServer, reso
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
localStore, err := localstore.New(dir, make([]byte, 32), nil)
|
||||
localStore, err := localstore.New(swarmDir, make([]byte, 32), nil)
|
||||
if err != nil {
|
||||
os.RemoveAll(swarmDir)
|
||||
t.Fatal(err)
|
||||
|
@ -309,6 +309,7 @@ func (r *Registry) getPeer(peerId enode.ID) *Peer {
|
||||
func (r *Registry) setPeer(peer *Peer) {
|
||||
r.peersMu.Lock()
|
||||
r.peers[peer.ID()] = peer
|
||||
metrics.GetOrRegisterCounter("registry.setpeer", nil).Inc(1)
|
||||
metrics.GetOrRegisterGauge("registry.peers", nil).Update(int64(len(r.peers)))
|
||||
r.peersMu.Unlock()
|
||||
}
|
||||
@ -316,6 +317,7 @@ func (r *Registry) setPeer(peer *Peer) {
|
||||
func (r *Registry) deletePeer(peer *Peer) {
|
||||
r.peersMu.Lock()
|
||||
delete(r.peers, peer.ID())
|
||||
metrics.GetOrRegisterCounter("registry.deletepeer", nil).Inc(1)
|
||||
metrics.GetOrRegisterGauge("registry.peers", nil).Update(int64(len(r.peers)))
|
||||
r.peersMu.Unlock()
|
||||
}
|
||||
|
@ -25,8 +25,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/shed"
|
||||
"github.com/ethereum/go-ethereum/swarm/spancontext"
|
||||
olog "github.com/opentracing/opentracing-go/log"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
@ -38,10 +36,6 @@ import (
|
||||
func (db *DB) Get(ctx context.Context, mode chunk.ModeGet, addr chunk.Address) (ch chunk.Chunk, err error) {
|
||||
metricName := fmt.Sprintf("localstore.Get.%s", mode)
|
||||
|
||||
ctx, sp := spancontext.StartSpan(ctx, metricName)
|
||||
defer sp.Finish()
|
||||
sp.LogFields(olog.String("ref", addr.String()), olog.String("mode-get", mode.String()))
|
||||
|
||||
metrics.GetOrRegisterCounter(metricName, nil).Inc(1)
|
||||
defer totalTimeMetric(metricName, time.Now())
|
||||
|
||||
|
@ -22,18 +22,12 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/spancontext"
|
||||
olog "github.com/opentracing/opentracing-go/log"
|
||||
)
|
||||
|
||||
// Has returns true if the chunk is stored in database.
|
||||
func (db *DB) Has(ctx context.Context, addr chunk.Address) (bool, error) {
|
||||
metricName := "localstore.Has"
|
||||
|
||||
ctx, sp := spancontext.StartSpan(ctx, metricName)
|
||||
defer sp.Finish()
|
||||
sp.LogFields(olog.String("ref", addr.String()))
|
||||
|
||||
metrics.GetOrRegisterCounter(metricName, nil).Inc(1)
|
||||
defer totalTimeMetric(metricName, time.Now())
|
||||
|
||||
|
@ -24,8 +24,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/shed"
|
||||
"github.com/ethereum/go-ethereum/swarm/spancontext"
|
||||
olog "github.com/opentracing/opentracing-go/log"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
@ -36,10 +34,6 @@ import (
|
||||
func (db *DB) Put(ctx context.Context, mode chunk.ModePut, ch chunk.Chunk) (exists bool, err error) {
|
||||
metricName := fmt.Sprintf("localstore.Put.%s", mode)
|
||||
|
||||
ctx, sp := spancontext.StartSpan(ctx, metricName)
|
||||
defer sp.Finish()
|
||||
sp.LogFields(olog.String("ref", ch.Address().String()), olog.String("mode-put", mode.String()))
|
||||
|
||||
metrics.GetOrRegisterCounter(metricName, nil).Inc(1)
|
||||
defer totalTimeMetric(metricName, time.Now())
|
||||
|
||||
|
@ -23,8 +23,6 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/spancontext"
|
||||
olog "github.com/opentracing/opentracing-go/log"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
@ -35,10 +33,6 @@ import (
|
||||
func (db *DB) Set(ctx context.Context, mode chunk.ModeSet, addr chunk.Address) (err error) {
|
||||
metricName := fmt.Sprintf("localstore.Set.%s", mode)
|
||||
|
||||
ctx, sp := spancontext.StartSpan(ctx, metricName)
|
||||
defer sp.Finish()
|
||||
sp.LogFields(olog.String("ref", addr.String()), olog.String("mode-set", mode.String()))
|
||||
|
||||
metrics.GetOrRegisterCounter(metricName, nil).Inc(1)
|
||||
defer totalTimeMetric(metricName, time.Now())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user