From 297fa1855c5ef933dd7a0e6299125244fa27cc4f Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Thu, 9 May 2019 17:16:19 +0200 Subject: [PATCH] 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 --- swarm/api/http/test_server.go | 2 +- swarm/network/stream/stream.go | 2 ++ swarm/storage/localstore/mode_get.go | 6 ------ swarm/storage/localstore/mode_has.go | 6 ------ swarm/storage/localstore/mode_put.go | 6 ------ swarm/storage/localstore/mode_set.go | 6 ------ 6 files changed, 3 insertions(+), 25 deletions(-) diff --git a/swarm/api/http/test_server.go b/swarm/api/http/test_server.go index fbb3366e2..a3be01e99 100644 --- a/swarm/api/http/test_server.go +++ b/swarm/api/http/test_server.go @@ -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) diff --git a/swarm/network/stream/stream.go b/swarm/network/stream/stream.go index 99235af66..9cdf5c04b 100644 --- a/swarm/network/stream/stream.go +++ b/swarm/network/stream/stream.go @@ -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() } diff --git a/swarm/storage/localstore/mode_get.go b/swarm/storage/localstore/mode_get.go index 191f4ebe5..efef82858 100644 --- a/swarm/storage/localstore/mode_get.go +++ b/swarm/storage/localstore/mode_get.go @@ -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()) diff --git a/swarm/storage/localstore/mode_has.go b/swarm/storage/localstore/mode_has.go index ae1a8970a..a70ee31b2 100644 --- a/swarm/storage/localstore/mode_has.go +++ b/swarm/storage/localstore/mode_has.go @@ -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()) diff --git a/swarm/storage/localstore/mode_put.go b/swarm/storage/localstore/mode_put.go index c91a394a0..a8e355ad0 100644 --- a/swarm/storage/localstore/mode_put.go +++ b/swarm/storage/localstore/mode_put.go @@ -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()) diff --git a/swarm/storage/localstore/mode_set.go b/swarm/storage/localstore/mode_set.go index 7edfa6703..14b48a22e 100644 --- a/swarm/storage/localstore/mode_set.go +++ b/swarm/storage/localstore/mode_set.go @@ -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())