aboutsummaryrefslogtreecommitdiffstats
path: root/swarm
diff options
context:
space:
mode:
authorAnton Evangelatov <anton.evangelatov@gmail.com>2019-03-08 15:52:25 +0800
committerViktor TrĂ³n <viktor.tron@gmail.com>2019-03-08 15:52:25 +0800
commit2cfe0bed9f0d96e3b0750cf3a6aa7f72894af53d (patch)
tree893a44e67b70de34fb183ef3c1d4d49596634da2 /swarm
parentceeb047e6958df32b5dacf0ce29e51c0314f905a (diff)
downloadgo-tangerine-2cfe0bed9f0d96e3b0750cf3a6aa7f72894af53d.tar
go-tangerine-2cfe0bed9f0d96e3b0750cf3a6aa7f72894af53d.tar.gz
go-tangerine-2cfe0bed9f0d96e3b0750cf3a6aa7f72894af53d.tar.bz2
go-tangerine-2cfe0bed9f0d96e3b0750cf3a6aa7f72894af53d.tar.lz
go-tangerine-2cfe0bed9f0d96e3b0750cf3a6aa7f72894af53d.tar.xz
go-tangerine-2cfe0bed9f0d96e3b0750cf3a6aa7f72894af53d.tar.zst
go-tangerine-2cfe0bed9f0d96e3b0750cf3a6aa7f72894af53d.zip
swarm: fix relationship between spans in open tracing (#19236)
* swarm/network: propagate span with ctx * swarm/network: try to stop stream.send.request spans on time * swarm/storage: add chunk ref as a log to netstore.fetcher span
Diffstat (limited to 'swarm')
-rw-r--r--swarm/network/fetcher.go11
-rw-r--r--swarm/network/stream/peer.go2
-rw-r--r--swarm/storage/netstore.go3
3 files changed, 15 insertions, 1 deletions
diff --git a/swarm/network/fetcher.go b/swarm/network/fetcher.go
index 6b2175166..3e6bb8904 100644
--- a/swarm/network/fetcher.go
+++ b/swarm/network/fetcher.go
@@ -18,12 +18,15 @@ package network
import (
"context"
+ "fmt"
"sync"
"time"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/swarm/storage"
+ "github.com/ethereum/go-ethereum/swarm/tracing"
+ "github.com/opentracing/opentracing-go"
)
const (
@@ -318,6 +321,14 @@ func (f *Fetcher) doRequest(gone chan *enode.ID, peersToSkip *sync.Map, sources
gone <- sourceID
case <-f.ctx.Done():
}
+
+ // finish the request span
+ spanId := fmt.Sprintf("stream.send.request.%v.%v", *sourceID, req.Addr)
+ span := tracing.ShiftSpanByKey(spanId)
+
+ if span != nil {
+ defer span.(opentracing.Span).Finish()
+ }
}()
return sources, nil
}
diff --git a/swarm/network/stream/peer.go b/swarm/network/stream/peer.go
index 1d3868a66..0f1472743 100644
--- a/swarm/network/stream/peer.go
+++ b/swarm/network/stream/peer.go
@@ -160,7 +160,7 @@ func (p *Peer) Deliver(ctx context.Context, chunk storage.Chunk, priority uint8,
// SendPriority sends message to the peer using the outgoing priority queue
func (p *Peer) SendPriority(ctx context.Context, msg interface{}, priority uint8) error {
defer metrics.GetOrRegisterResettingTimer(fmt.Sprintf("peer.sendpriority_t.%d", priority), nil).UpdateSince(time.Now())
- tracing.StartSaveSpan(ctx)
+ ctx = tracing.StartSaveSpan(ctx)
metrics.GetOrRegisterCounter(fmt.Sprintf("peer.sendpriority.%d", priority), nil).Inc(1)
wmsg := WrappedPriorityMsg{
Context: ctx,
diff --git a/swarm/storage/netstore.go b/swarm/storage/netstore.go
index 8a44f51a8..9e32578a8 100644
--- a/swarm/storage/netstore.go
+++ b/swarm/storage/netstore.go
@@ -28,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/spancontext"
"github.com/opentracing/opentracing-go"
+ olog "github.com/opentracing/opentracing-go/log"
lru "github.com/hashicorp/golang-lru"
)
@@ -215,6 +216,8 @@ func (n *NetStore) getOrCreateFetcher(ctx context.Context, ref Address) *fetcher
cctx,
"netstore.fetcher",
)
+
+ sp.LogFields(olog.String("ref", ref.String()))
fetcher := newFetcher(sp, ref, n.NewNetFetcherFunc(cctx, ref, peers), destroy, peers, n.closeC)
n.fetchers.Add(key, fetcher)