Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
006de07d
Unverified
Commit
006de07d
authored
Sep 22, 2020
by
acud
Committed by
GitHub
Sep 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tracing (#729)
parent
22d7e53b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
13 deletions
+12
-13
pusher.go
pkg/pusher/pusher.go
+0
-1
pushsync.go
pkg/pushsync/pushsync.go
+4
-4
retrieval.go
pkg/retrieval/retrieval.go
+3
-4
tracing.go
pkg/tracing/tracing.go
+5
-4
No files found.
pkg/pusher/pusher.go
View file @
006de07d
...
...
@@ -59,7 +59,6 @@ func (s *Service) chunksWorker() {
<-
s
.
quit
cancel
()
}()
sem
:=
make
(
chan
struct
{},
10
)
inflight
:=
make
(
map
[
string
]
struct
{})
var
mtx
sync
.
Mutex
...
...
pkg/pushsync/pushsync.go
View file @
006de07d
...
...
@@ -20,6 +20,7 @@ import (
"github.com/ethersphere/bee/pkg/tags"
"github.com/ethersphere/bee/pkg/topology"
"github.com/ethersphere/bee/pkg/tracing"
"github.com/opentracing/opentracing-go"
)
const
(
...
...
@@ -62,6 +63,7 @@ func New(streamer p2p.Streamer, storer storage.Putter, closestPeerer topology.Cl
accounting
:
accounting
,
pricer
:
pricer
,
metrics
:
newMetrics
(),
tracer
:
tracer
,
}
return
ps
}
...
...
@@ -95,8 +97,7 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"chunk delivery from peer %s: %w"
,
p
.
Address
.
String
(),
err
)
}
span
,
_
,
ctx
:=
ps
.
tracer
.
StartSpanFromContext
(
ctx
,
"pushsync-handler"
,
ps
.
logger
)
span
=
span
.
SetTag
(
"address"
,
chunk
.
Address
()
.
String
())
span
,
_
,
ctx
:=
ps
.
tracer
.
StartSpanFromContext
(
ctx
,
"pushsync-handler"
,
ps
.
logger
,
opentracing
.
Tag
{
Key
:
"address"
,
Value
:
chunk
.
Address
()
.
String
()})
defer
span
.
Finish
()
// Select the closest peer to forward the chunk
...
...
@@ -219,8 +220,7 @@ func (ps *PushSync) receiveReceipt(r protobuf.Reader) (receipt pb.Receipt, err e
// a receipt from that peer and returns error or nil based on the receiving and
// the validity of the receipt.
func
(
ps
*
PushSync
)
PushChunkToClosest
(
ctx
context
.
Context
,
ch
swarm
.
Chunk
)
(
*
Receipt
,
error
)
{
span
,
_
,
ctx
:=
ps
.
tracer
.
StartSpanFromContext
(
ctx
,
"pushsync-push"
,
ps
.
logger
)
span
=
span
.
SetTag
(
"address"
,
ch
.
Address
()
.
String
())
span
,
_
,
ctx
:=
ps
.
tracer
.
StartSpanFromContext
(
ctx
,
"pushsync-push"
,
ps
.
logger
,
opentracing
.
Tag
{
Key
:
"address"
,
Value
:
ch
.
Address
()
.
String
()})
defer
span
.
Finish
()
peer
,
err
:=
ps
.
peerSuggester
.
ClosestPeer
(
ch
.
Address
())
...
...
pkg/retrieval/retrieval.go
View file @
006de07d
...
...
@@ -18,6 +18,7 @@ import (
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/topology"
"github.com/ethersphere/bee/pkg/tracing"
"github.com/opentracing/opentracing-go"
"golang.org/x/sync/singleflight"
)
...
...
@@ -84,8 +85,7 @@ func (s *Service) RetrieveChunk(ctx context.Context, addr swarm.Address) (swarm.
defer
cancel
()
v
,
err
,
_
:=
s
.
singleflight
.
Do
(
addr
.
String
(),
func
()
(
interface
{},
error
)
{
span
,
logger
,
ctx
:=
s
.
tracer
.
StartSpanFromContext
(
ctx
,
"retrieve-chunk"
,
s
.
logger
)
span
=
span
.
SetTag
(
"address"
,
addr
.
String
())
span
,
logger
,
ctx
:=
s
.
tracer
.
StartSpanFromContext
(
ctx
,
"retrieve-chunk"
,
s
.
logger
,
opentracing
.
Tag
{
Key
:
"address"
,
Value
:
addr
.
String
()})
defer
span
.
Finish
()
var
skipPeers
[]
swarm
.
Address
...
...
@@ -238,8 +238,7 @@ func (s *Service) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) (e
if
err
:=
r
.
ReadMsg
(
&
req
);
err
!=
nil
{
return
fmt
.
Errorf
(
"read request: %w peer %s"
,
err
,
p
.
Address
.
String
())
}
span
,
_
,
ctx
:=
s
.
tracer
.
StartSpanFromContext
(
ctx
,
"handle-retrieve-chunk"
,
s
.
logger
)
span
=
span
.
SetTag
(
"address"
,
swarm
.
NewAddress
(
req
.
Addr
)
.
String
())
span
,
_
,
ctx
:=
s
.
tracer
.
StartSpanFromContext
(
ctx
,
"handle-retrieve-chunk"
,
s
.
logger
,
opentracing
.
Tag
{
Key
:
"address"
,
Value
:
swarm
.
NewAddress
(
req
.
Addr
)
.
String
()})
defer
span
.
Finish
()
ctx
=
context
.
WithValue
(
ctx
,
requestSourceContextKey
{},
p
.
Address
.
String
())
...
...
pkg/tracing/tracing.go
View file @
006de07d
...
...
@@ -25,12 +25,13 @@ var (
// in p2p Headers or context.
ErrContextNotFound
=
errors
.
New
(
"tracing context not found"
)
// contextKey is used to reference a tracing context span as context value.
contextKey
=
struct
{}{}
// noopTracer is the tracer that does nothing to handle a nil Tracer usage.
noopTracer
=
&
Tracer
{
tracer
:
new
(
opentracing
.
NoopTracer
)}
)
// contextKey is used to reference a tracing context span as context value.
type
contextKey
struct
{}
// LogField is the key in log message field that holds tracing id value.
const
LogField
=
"traceid"
...
...
@@ -160,13 +161,13 @@ func (t *Tracer) WithContextFromHeaders(ctx context.Context, headers p2p.Headers
// WithContext adds tracing span context to go context.
func
WithContext
(
ctx
context
.
Context
,
c
opentracing
.
SpanContext
)
context
.
Context
{
return
context
.
WithValue
(
ctx
,
contextKey
,
c
)
return
context
.
WithValue
(
ctx
,
contextKey
{}
,
c
)
}
// FromContext return tracing span context from go context. If the tracing span
// context is not present in go context, nil is returned.
func
FromContext
(
ctx
context
.
Context
)
opentracing
.
SpanContext
{
c
,
ok
:=
ctx
.
Value
(
contextKey
)
.
(
opentracing
.
SpanContext
)
c
,
ok
:=
ctx
.
Value
(
contextKey
{}
)
.
(
opentracing
.
SpanContext
)
if
!
ok
{
return
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment