@@ -108,9 +108,11 @@ func TickerDuration(d, e time.Duration) {
108
108
// act like 1s has elapsed. This is for test plans with realistic whole-second
109
109
// durations. The RBB tests use 100ms/100ms because that test plan is design for
110
110
// 100ms intervals, so it can run through 5 intervals in about 500ms.
111
- var tickerMux = & sync.Mutex {} // make go test -race happy
112
- var tickerDuration = 1 * time .Second // used for testing
113
- var timeElapsed = 1 * time .Second // used for testing
111
+ var (
112
+ tickerMux = & sync.Mutex {} // make go test -race happy
113
+ tickerDuration = 1 * time .Second // used for testing
114
+ timeElapsed = 1 * time .Second // used for testing
115
+ )
114
116
115
117
// recvMetrics receives metrics on metricsChan and send them to all the sinks.
116
118
// This is a goroutine run by keepRecvMetrics and restarted by keepRecvMetrics
@@ -123,7 +125,7 @@ func (c *lco) recvMetrics(stopSinksChan, doneChan chan struct{}) {
123
125
b := make ([]byte , 4096 )
124
126
n := runtime .Stack (b , false )
125
127
perr := fmt .Errorf ("PANIC: sinks: %s: %v\n %s" , c .monitorId , r , string (b [0 :n ]))
126
- c .event .Errorf (event .LCO_RECEIVER_PANIC , perr .Error ())
128
+ c .event .Error (event .LCO_RECEIVER_PANIC , perr .Error ())
127
129
}
128
130
}()
129
131
RECV:
@@ -145,11 +147,11 @@ RECV:
145
147
coId := fmt .Sprintf ("%s/%s/%d" , m .Plan , m .Level , m .Interval )
146
148
for _ , sink := range c .sinks {
147
149
sinkName := sink .Name ()
148
- status .Monitor (c .monitorId , status .LEVEL_SINKS , coId + ": sending to " + sinkName )
150
+ status .Monitor (c .monitorId , status .LEVEL_SINKS , "%s" , coId + ": sending to " + sinkName )
149
151
err := sink .Send (context .Background (), m ) // @todo ctx with timeout
150
152
if err != nil {
151
153
c .event .Errorf (event .SINK_SEND_ERROR , "%s :%s" , sinkName , err ) // log by default
152
- status .Monitor (c .monitorId , "error:" + sinkName , err .Error ())
154
+ status .Monitor (c .monitorId , "error:" + sinkName , "%s" , err .Error ())
153
155
} else {
154
156
status .RemoveComponent (c .monitorId , "error:" + sinkName )
155
157
}
@@ -279,8 +281,8 @@ func (c *lco) collect(interval uint, levelName string, startTime time.Time) {
279
281
blip .Debug ("%s: level %s: done in %s" , c .monitorId , levelName , metrics [0 ].End .Sub (metrics [0 ].Begin ))
280
282
281
283
if err != nil {
282
- status .Monitor (c .monitorId , "error:collect" , err .Error ())
283
- c .event .Errorf (event .ENGINE_COLLECT_ERROR , err .Error ())
284
+ status .Monitor (c .monitorId , "error:collect" , "%s" , err .Error ())
285
+ c .event .Error (event .ENGINE_COLLECT_ERROR , err .Error ())
284
286
} else {
285
287
status .RemoveComponent (c .monitorId , "error:collect" )
286
288
}
@@ -368,7 +370,7 @@ func (c *lco) changePlan(ctx context.Context, doneChan chan struct{}, newState,
368
370
oldPlanName := c .plan .Name
369
371
c .stateMux .Unlock ()
370
372
change := fmt .Sprintf ("state:%s plan:%s -> state:%s plan:%s" , oldState , oldPlanName , newState , newPlanName )
371
- c .event .Sendf (event .CHANGE_PLAN , change )
373
+ c .event .Sendf (event .CHANGE_PLAN , "%s" , change )
372
374
373
375
// Load new plan from plan loader, which contains all plans. Try forever because
374
376
// that's what this func/gouroutine does: try forever (caller's expect that).
@@ -385,8 +387,8 @@ func (c *lco) changePlan(ctx context.Context, doneChan chan struct{}, newState,
385
387
}
386
388
387
389
errMsg := fmt .Sprintf ("%s: error loading new plan %s: %s (retrying)" , change , newPlanName , err )
388
- status .Monitor (c .monitorId , status .LEVEL_CHANGE_PLAN , errMsg )
389
- c .event .Sendf (event .CHANGE_PLAN_ERROR , errMsg )
390
+ status .Monitor (c .monitorId , status .LEVEL_CHANGE_PLAN , "%s" , errMsg )
391
+ c .event .Sendf (event .CHANGE_PLAN_ERROR , "%s" , errMsg )
390
392
time .Sleep (2 * time .Second )
391
393
}
392
394
@@ -428,8 +430,8 @@ func (c *lco) changePlan(ctx context.Context, doneChan chan struct{}, newState,
428
430
// Changing state/plan always resumes (if paused); in fact, it's the
429
431
// only way to resume after Pause is called
430
432
c .paused = false
431
- status .Monitor (c .monitorId , status .LEVEL_STATE , newState )
432
- status .Monitor (c .monitorId , status .LEVEL_PLAN , newPlan .Name )
433
+ status .Monitor (c .monitorId , status .LEVEL_STATE , "%s" , newState )
434
+ status .Monitor (c .monitorId , status .LEVEL_PLAN , "%s" , newPlan .Name )
433
435
status .Monitor (c .monitorId , status .LEVEL_COLLECTOR , "running since %s" , blip .FormatTime (time .Now ()))
434
436
blip .Debug ("%s: resume" , c .monitorId )
435
437
@@ -466,7 +468,7 @@ func (c *lco) changePlan(ctx context.Context, doneChan chan struct{}, newState,
466
468
}
467
469
468
470
status .RemoveComponent (c .monitorId , status .LEVEL_CHANGE_PLAN )
469
- c .event .Sendf (event .CHANGE_PLAN_SUCCESS , change )
471
+ c .event .Sendf (event .CHANGE_PLAN_SUCCESS , "%s" , change )
470
472
}
471
473
472
474
// Pause pauses metrics collection until ChangePlan is called. Run still runs,
0 commit comments