swarm: tracing improvements (#19249)
This commit is contained in:
committed by
GitHub
parent
9a58a9b91a
commit
1a3e25e4c1
@ -26,7 +26,7 @@ import (
|
||||
"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"
|
||||
olog "github.com/opentracing/opentracing-go/log"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -327,7 +327,8 @@ func (f *Fetcher) doRequest(gone chan *enode.ID, peersToSkip *sync.Map, sources
|
||||
span := tracing.ShiftSpanByKey(spanId)
|
||||
|
||||
if span != nil {
|
||||
defer span.(opentracing.Span).Finish()
|
||||
span.LogFields(olog.String("finish", "from doRequest"))
|
||||
span.Finish()
|
||||
}
|
||||
}()
|
||||
return sources, nil
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
||||
"github.com/ethereum/go-ethereum/swarm/tracing"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
olog "github.com/opentracing/opentracing-go/log"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -146,6 +147,8 @@ func (d *Delivery) handleRetrieveRequestMsg(ctx context.Context, sp *Peer, req *
|
||||
ctx,
|
||||
"stream.handle.retrieve")
|
||||
|
||||
osp.LogFields(olog.String("ref", req.Addr.String()))
|
||||
|
||||
s, err := sp.getServer(NewStream(swarmChunkServerStreamName, "", true))
|
||||
if err != nil {
|
||||
return err
|
||||
@ -176,12 +179,15 @@ func (d *Delivery) handleRetrieveRequestMsg(ctx context.Context, sp *Peer, req *
|
||||
}
|
||||
if req.SkipCheck {
|
||||
syncing := false
|
||||
osp.LogFields(olog.Bool("skipCheck", true))
|
||||
|
||||
err = sp.Deliver(ctx, chunk, s.priority, syncing)
|
||||
if err != nil {
|
||||
log.Warn("ERROR in handleRetrieveRequestMsg", "err", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
osp.LogFields(olog.Bool("skipCheck", false))
|
||||
select {
|
||||
case streamer.deliveryC <- chunk.Address()[:]:
|
||||
case <-streamer.quit:
|
||||
@ -219,7 +225,8 @@ func (d *Delivery) handleChunkDeliveryMsg(ctx context.Context, sp *Peer, req *Ch
|
||||
|
||||
go func() {
|
||||
if span != nil {
|
||||
defer span.(opentracing.Span).Finish()
|
||||
span.LogFields(olog.String("finish", "from handleChunkDeliveryMsg"))
|
||||
defer span.Finish()
|
||||
}
|
||||
|
||||
req.peer = sp
|
||||
|
@ -167,9 +167,8 @@ func (p *Peer) SendPriority(ctx context.Context, msg interface{}, priority uint8
|
||||
Msg: msg,
|
||||
}
|
||||
err := p.pq.Push(wmsg, int(priority))
|
||||
if err == pq.ErrContention {
|
||||
log.Warn("dropping peer on priority queue contention", "peer", p.ID())
|
||||
p.Drop(err)
|
||||
if err != nil {
|
||||
log.Error("err on p.pq.Push", "err", err, "peer", p.ID())
|
||||
}
|
||||
return err
|
||||
}
|
||||
@ -183,6 +182,8 @@ func (p *Peer) SendOfferedHashes(s *server, f, t uint64) error {
|
||||
)
|
||||
defer sp.Finish()
|
||||
|
||||
defer metrics.GetOrRegisterResettingTimer("send.offered.hashes", nil).UpdateSince(time.Now())
|
||||
|
||||
hashes, from, to, proof, err := s.setNextBatch(f, t)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -103,6 +103,14 @@ func (n *NetStore) Get(rctx context.Context, ref Address) (Chunk, error) {
|
||||
return nil, err
|
||||
}
|
||||
if chunk != nil {
|
||||
// this is not measuring how long it takes to get the chunk for the localstore, but
|
||||
// rather just adding a span for clarity when inspecting traces in Jaeger, in order
|
||||
// to make it easier to reason which is the node that actually delivered a chunk.
|
||||
_, sp := spancontext.StartSpan(
|
||||
rctx,
|
||||
"localstore.get")
|
||||
defer sp.Finish()
|
||||
|
||||
return chunk, nil
|
||||
}
|
||||
return fetch(rctx)
|
||||
|
Reference in New Issue
Block a user