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 {
101
101
r .stats = & RecorderStats {}
102
102
r .logger .Printf ("recorder frequency: %v" , agent .flushFrequency )
103
103
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
+ }
104
111
r .t .Go (r .loop )
105
112
return r
106
113
}
@@ -122,18 +129,8 @@ func (r *SpanRecorder) RecordSpan(span tracer.RawSpan) {
122
129
123
130
func (r * SpanRecorder ) loop () error {
124
131
defer func () {
125
- close (r .workerJobs )
126
- close (r .workerResults )
127
132
r .logger .Println ("recorder has been stopped." )
128
133
}()
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
-
137
134
ticker := time .NewTicker (1 * time .Second )
138
135
cTime := time .Now ()
139
136
for {
@@ -280,6 +277,8 @@ func (r *SpanRecorder) Stop() {
280
277
}
281
278
r .t .Kill (nil )
282
279
_ = r .t .Wait ()
280
+ close (r .workerJobs )
281
+ close (r .workerResults )
283
282
if r .debugMode {
284
283
r .writeStats ()
285
284
}
You can’t perform that action at this time.
0 commit comments