This repository was archived by the owner on Aug 17, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,13 @@ func NewSpanRecorder(agent *Agent) *SpanRecorder {
101101 r .stats = & RecorderStats {}
102102 r .logger .Printf ("recorder frequency: %v" , agent .flushFrequency )
103103 r .logger .Printf ("recorder concurrency level: %v" , agent .concurrencyLevel )
104+
105+ // start workers
106+ r .workerJobs = make (chan * workerJob , r .concurrencyLevel )
107+ r .workerResults = make (chan * workerResult , r .concurrencyLevel )
108+ for i := 0 ; i < r .concurrencyLevel ; i ++ {
109+ go r .worker (i + 1 )
110+ }
104111 r .t .Go (r .loop )
105112 return r
106113}
@@ -122,18 +129,8 @@ func (r *SpanRecorder) RecordSpan(span tracer.RawSpan) {
122129
123130func (r * SpanRecorder ) loop () error {
124131 defer func () {
125- close (r .workerJobs )
126- close (r .workerResults )
127132 r .logger .Println ("recorder has been stopped." )
128133 }()
129-
130- // start workers
131- r .workerJobs = make (chan * workerJob , r .concurrencyLevel )
132- r .workerResults = make (chan * workerResult , r .concurrencyLevel )
133- for i := 0 ; i < r .concurrencyLevel ; i ++ {
134- go r .worker (i + 1 )
135- }
136-
137134 ticker := time .NewTicker (1 * time .Second )
138135 cTime := time .Now ()
139136 for {
@@ -280,6 +277,8 @@ func (r *SpanRecorder) Stop() {
280277 }
281278 r .t .Kill (nil )
282279 _ = r .t .Wait ()
280+ close (r .workerJobs )
281+ close (r .workerResults )
283282 if r .debugMode {
284283 r .writeStats ()
285284 }
You can’t perform that action at this time.
0 commit comments