@@ -69,11 +69,14 @@ func (r *Retryer) runRetryLoop(
6969 li := & LoopInfo {
7070 durationLimit : r .retryLimit ,
7171 }
72- funcinfos := lo .RepeatBy (
73- len ( r .callbacks ) ,
74- func (_ int ) * FuncInfo {
72+ funcinfos := lo .Map (
73+ r .callbacks ,
74+ func (cb retryCallbackInfo , _ int ) * FuncInfo {
7575 return & FuncInfo {
76- lastResetTime : msync .NewTypedAtomic (startTime ),
76+ lastReset : msync .NewTypedAtomic (lastResetInfo {
77+ time : startTime ,
78+ }),
79+ description : cb .description ,
7780 loopDescription : r .description ,
7881 loopInfo : li ,
7982 }
@@ -113,17 +116,25 @@ func (r *Retryer) runRetryLoop(
113116 defer ticker .Stop ()
114117
115118 for {
116- lastSuccessTime := funcinfos [i ].lastResetTime .Load ()
119+ lastReset := funcinfos [i ].lastReset .Load ()
117120
118121 select {
119122 case <- cbDoneChan :
120123 return
121124 case <- ticker .C :
122- if funcinfos [i ].lastResetTime .Load () == lastSuccessTime {
123- logger .Warn ().
125+ if funcinfos [i ].lastReset .Load () == lastReset {
126+ event := logger .Warn ().
124127 Str ("callbackDescription" , curCbInfo .description ).
125- Time ("lastSuccessAt" , lastSuccessTime ).
126- Str ("elapsedTime" , reportutils .DurationToHMS (time .Since (lastSuccessTime ))).
128+ Time ("since" , lastReset .time )
129+
130+ if successDesc , hasDesc := lastReset .description .Get (); hasDesc {
131+ event .
132+ Str ("successDescription" , successDesc ).
133+ Uint64 ("successesSoFar" , lastReset .resetsSoFar )
134+ }
135+
136+ event .
137+ Str ("elapsedTime" , reportutils .DurationToHMS (time .Since (lastReset .time ))).
127138 Msg ("Operation has not reported success for a while." )
128139 }
129140 }
@@ -164,9 +175,11 @@ func (r *Retryer) runRetryLoop(
164175 }
165176
166177 failedFuncInfo := funcinfos [groupErr .funcNum ]
178+ descriptions := failedFuncInfo .GetDescriptions ()
179+ cbErr := groupErr .errFromCallback
167180
168181 // Not a transient error? Fail immediately.
169- if ! r .shouldRetryWithSleep (logger , sleepTime , r . callbacks [ groupErr . funcNum ], groupErr . errFromCallback ) {
182+ if ! r .shouldRetryWithSleep (logger , sleepTime , descriptions , cbErr ) {
170183 return groupErr .errFromCallback
171184 }
172185
@@ -201,7 +214,7 @@ func (r *Retryer) runRetryLoop(
201214 // Set all of the funcs that did *not* fail as having just succeeded.
202215 for i , curInfo := range funcinfos {
203216 if i != groupErr .funcNum {
204- curInfo .lastResetTime .Store (now )
217+ curInfo .lastReset .Store (lastResetInfo { time : now } )
205218 }
206219 }
207220 }
@@ -235,7 +248,7 @@ func (r *Retryer) addDescriptionToEvent(event *zerolog.Event) *zerolog.Event {
235248func (r * Retryer ) shouldRetryWithSleep (
236249 logger * logger.Logger ,
237250 sleepTime time.Duration ,
238- cbInfo retryCallbackInfo ,
251+ descriptions [] string ,
239252 err error ,
240253) bool {
241254 if err == nil {
@@ -266,11 +279,7 @@ func (r *Retryer) shouldRetryWithSleep(
266279 ),
267280 )
268281
269- if loopDesc , hasLoopDesc := r .description .Get (); hasLoopDesc {
270- event .Str ("operationDescription" , loopDesc )
271- }
272-
273- event .Str ("callbackDescription" , cbInfo .description ).
282+ event .Strs ("description" , descriptions ).
274283 Int ("error code" , util .GetErrorCode (err )).
275284 Err (err )
276285
0 commit comments