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
f5aa9716
Unverified
Commit
f5aa9716
authored
Sep 24, 2020
by
acud
Committed by
GitHub
Sep 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pusher: add tracing (#746)
* add tracing to pusher
parent
a1765172
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
7 deletions
+33
-7
node.go
pkg/node/node.go
+1
-1
pusher.go
pkg/pusher/pusher.go
+29
-4
pusher_test.go
pkg/pusher/pusher_test.go
+3
-2
No files found.
pkg/node/node.go
View file @
f5aa9716
...
@@ -353,7 +353,7 @@ func NewBee(addr string, swarmAddress swarm.Address, keystore keystore.Service,
...
@@ -353,7 +353,7 @@ func NewBee(addr string, swarmAddress swarm.Address, keystore keystore.Service,
b
.
recoveryHandleCleanup
=
psss
.
Register
(
recovery
.
RecoveryTopic
,
chunkRepairHandler
)
b
.
recoveryHandleCleanup
=
psss
.
Register
(
recovery
.
RecoveryTopic
,
chunkRepairHandler
)
}
}
pushSyncPusher
:=
pusher
.
New
(
storer
,
kad
,
pushSyncProtocol
,
tagg
,
logger
)
pushSyncPusher
:=
pusher
.
New
(
storer
,
kad
,
pushSyncProtocol
,
tagg
,
logger
,
tracer
)
b
.
pusherCloser
=
pushSyncPusher
b
.
pusherCloser
=
pushSyncPusher
pullStorage
:=
pullstorage
.
New
(
storer
)
pullStorage
:=
pullstorage
.
New
(
storer
)
...
...
pkg/pusher/pusher.go
View file @
f5aa9716
...
@@ -16,6 +16,8 @@ import (
...
@@ -16,6 +16,8 @@ import (
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/tags"
"github.com/ethersphere/bee/pkg/tags"
"github.com/ethersphere/bee/pkg/topology"
"github.com/ethersphere/bee/pkg/topology"
"github.com/ethersphere/bee/pkg/tracing"
"github.com/opentracing/opentracing-go"
)
)
type
Service
struct
{
type
Service
struct
{
...
@@ -23,19 +25,21 @@ type Service struct {
...
@@ -23,19 +25,21 @@ type Service struct {
pushSyncer
pushsync
.
PushSyncer
pushSyncer
pushsync
.
PushSyncer
logger
logging
.
Logger
logger
logging
.
Logger
tagg
*
tags
.
Tags
tagg
*
tags
.
Tags
tracer
*
tracing
.
Tracer
metrics
metrics
metrics
metrics
quit
chan
struct
{}
quit
chan
struct
{}
chunksWorkerQuitC
chan
struct
{}
chunksWorkerQuitC
chan
struct
{}
}
}
var
retryInterval
=
10
*
time
.
Second
// time interval between retries
var
retryInterval
=
5
*
time
.
Second
// time interval between retries
func
New
(
storer
storage
.
Storer
,
peerSuggester
topology
.
ClosestPeerer
,
pushSyncer
pushsync
.
PushSyncer
,
tagger
*
tags
.
Tags
,
logger
logging
.
Logger
)
*
Service
{
func
New
(
storer
storage
.
Storer
,
peerSuggester
topology
.
ClosestPeerer
,
pushSyncer
pushsync
.
PushSyncer
,
tagger
*
tags
.
Tags
,
logger
logging
.
Logger
,
tracer
*
tracing
.
Tracer
)
*
Service
{
service
:=
&
Service
{
service
:=
&
Service
{
storer
:
storer
,
storer
:
storer
,
pushSyncer
:
pushSyncer
,
pushSyncer
:
pushSyncer
,
tagg
:
tagger
,
tagg
:
tagger
,
logger
:
logger
,
logger
:
logger
,
tracer
:
tracer
,
metrics
:
newMetrics
(),
metrics
:
newMetrics
(),
quit
:
make
(
chan
struct
{}),
quit
:
make
(
chan
struct
{}),
chunksWorkerQuitC
:
make
(
chan
struct
{}),
chunksWorkerQuitC
:
make
(
chan
struct
{}),
...
@@ -54,7 +58,7 @@ func (s *Service) chunksWorker() {
...
@@ -54,7 +58,7 @@ func (s *Service) chunksWorker() {
defer
timer
.
Stop
()
defer
timer
.
Stop
()
defer
close
(
s
.
chunksWorkerQuitC
)
defer
close
(
s
.
chunksWorkerQuitC
)
chunksInBatch
:=
-
1
chunksInBatch
:=
-
1
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
c
c
tx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
go
func
()
{
go
func
()
{
<-
s
.
quit
<-
s
.
quit
cancel
()
cancel
()
...
@@ -62,13 +66,15 @@ func (s *Service) chunksWorker() {
...
@@ -62,13 +66,15 @@ func (s *Service) chunksWorker() {
sem
:=
make
(
chan
struct
{},
10
)
sem
:=
make
(
chan
struct
{},
10
)
inflight
:=
make
(
map
[
string
]
struct
{})
inflight
:=
make
(
map
[
string
]
struct
{})
var
mtx
sync
.
Mutex
var
mtx
sync
.
Mutex
var
span
opentracing
.
Span
ctx
:=
cctx
LOOP
:
LOOP
:
for
{
for
{
select
{
select
{
// handle incoming chunks
// handle incoming chunks
case
ch
,
more
:=
<-
chunks
:
case
ch
,
more
:=
<-
chunks
:
// if no more, set to nil, reset timer to
0 to finalise batch immediately
// if no more, set to nil, reset timer to
finalise batch
if
!
more
{
if
!
more
{
chunks
=
nil
chunks
=
nil
var
dur
time
.
Duration
var
dur
time
.
Duration
...
@@ -79,6 +85,10 @@ LOOP:
...
@@ -79,6 +85,10 @@ LOOP:
break
break
}
}
if
span
==
nil
{
span
,
_
,
ctx
=
s
.
tracer
.
StartSpanFromContext
(
cctx
,
"pusher-sync-batch"
,
s
.
logger
)
}
// postpone a retry only after we've finished processing everything in index
// postpone a retry only after we've finished processing everything in index
timer
.
Reset
(
retryInterval
)
timer
.
Reset
(
retryInterval
)
chunksInBatch
++
chunksInBatch
++
...
@@ -89,6 +99,10 @@ LOOP:
...
@@ -89,6 +99,10 @@ LOOP:
if
unsubscribe
!=
nil
{
if
unsubscribe
!=
nil
{
unsubscribe
()
unsubscribe
()
}
}
if
span
!=
nil
{
span
.
Finish
()
}
return
return
}
}
mtx
.
Lock
()
mtx
.
Lock
()
...
@@ -138,6 +152,8 @@ LOOP:
...
@@ -138,6 +152,8 @@ LOOP:
unsubscribe
()
unsubscribe
()
}
}
chunksInBatch
=
0
// and start iterating on Push index from the beginning
// and start iterating on Push index from the beginning
chunks
,
unsubscribe
=
s
.
storer
.
SubscribePush
(
ctx
)
chunks
,
unsubscribe
=
s
.
storer
.
SubscribePush
(
ctx
)
...
@@ -145,10 +161,19 @@ LOOP:
...
@@ -145,10 +161,19 @@ LOOP:
timer
.
Reset
(
retryInterval
)
timer
.
Reset
(
retryInterval
)
s
.
metrics
.
MarkAndSweepTimer
.
Observe
(
time
.
Since
(
startTime
)
.
Seconds
())
s
.
metrics
.
MarkAndSweepTimer
.
Observe
(
time
.
Since
(
startTime
)
.
Seconds
())
if
span
!=
nil
{
span
.
Finish
()
span
=
nil
}
case
<-
s
.
quit
:
case
<-
s
.
quit
:
if
unsubscribe
!=
nil
{
if
unsubscribe
!=
nil
{
unsubscribe
()
unsubscribe
()
}
}
if
span
!=
nil
{
span
.
Finish
()
}
break
LOOP
break
LOOP
}
}
}
}
...
...
pkg/pusher/pusher_test.go
View file @
f5aa9716
...
@@ -7,12 +7,13 @@ package pusher_test
...
@@ -7,12 +7,13 @@ package pusher_test
import
(
import
(
"context"
"context"
"errors"
"errors"
statestore
"github.com/ethersphere/bee/pkg/statestore/mock"
"io/ioutil"
"io/ioutil"
"sync"
"sync"
"testing"
"testing"
"time"
"time"
statestore
"github.com/ethersphere/bee/pkg/statestore/mock"
"github.com/ethersphere/bee/pkg/localstore"
"github.com/ethersphere/bee/pkg/localstore"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/pusher"
"github.com/ethersphere/bee/pkg/pusher"
...
@@ -237,7 +238,7 @@ func createPusher(t *testing.T, addr swarm.Address, pushSyncService pushsync.Pus
...
@@ -237,7 +238,7 @@ func createPusher(t *testing.T, addr swarm.Address, pushSyncService pushsync.Pus
}
}
peerSuggester
:=
mock
.
NewTopologyDriver
(
mockOpts
...
)
peerSuggester
:=
mock
.
NewTopologyDriver
(
mockOpts
...
)
pusherService
:=
pusher
.
New
(
pusherStorer
,
peerSuggester
,
pushSyncService
,
mtags
,
logger
)
pusherService
:=
pusher
.
New
(
pusherStorer
,
peerSuggester
,
pushSyncService
,
mtags
,
logger
,
nil
)
return
mtags
,
pusherService
,
pusherStorer
return
mtags
,
pusherService
,
pusherStorer
}
}
...
...
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