swarm/network: try to stop stream.send.request spans on time

This commit is contained in:
Anton Evangelatov 2019-03-07 17:50:05 +01:00
parent 4533a2b76a
commit e38bd0195b

View file

@ -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
}