srijeet0406 commented on code in PR #7539:
URL: https://github.com/apache/trafficcontrol/pull/7539#discussion_r1210991253
##########
traffic_monitor/health/cache.go:
##########
@@ -115,7 +115,10 @@ func GetVitals(newResult *cache.Result, prevResult
*cache.Result, mc *tc.Traffic
}
if prevResult != nil && prevResult.InterfaceVitals != nil &&
prevResult.InterfaceVitals[ifaceName].BytesOut != 0 {
- elapsedTimeInSecs :=
float64(newResult.Time.UnixNano()-prevResult.Time.UnixNano()) / 1000000000
+ elapsedTimeInSecs :=
float64(newResult.Time.UnixMilli()-prevResult.Time.UnixMilli()) / 1000
Review Comment:
Any particular reason behind chanhing this from nanoseconds to milliseconds?
##########
traffic_monitor/cache/cache.go:
##########
@@ -300,6 +301,14 @@ func (handler Handler) Handle(id string, rdr io.Reader,
format string, reqTime t
}
stats, miscStats, err := decoder.Parse(result.ID, rdr, pollCtx)
+ if val, ok := miscStats["current_time_epoch_ms"]; ok {
Review Comment:
We shouldThis should happen after the error from line 304 is handled.
##########
traffic_monitor/cache/cache.go:
##########
@@ -300,6 +301,14 @@ func (handler Handler) Handle(id string, rdr io.Reader,
format string, reqTime t
}
stats, miscStats, err := decoder.Parse(result.ID, rdr, pollCtx)
+ if val, ok := miscStats["current_time_epoch_ms"]; ok {
+ valString := fmt.Sprintf("%s", val)
+ valInt, err := strconv.ParseInt(valString, 10, 64)
+ if err != nil {
Review Comment:
If this conversion fails, should it still try to convert `valInt` into a
time value on line 310? Shouldn't it just error out like in line 314?
##########
traffic_monitor/health/cache.go:
##########
@@ -128,7 +131,10 @@ func GetVitals(newResult *cache.Result, prevResult
*cache.Result, mc *tc.Traffic
}
if prevResult != nil && prevResult.Vitals.BytesOut != 0 {
- elapsedTimeInSecs :=
float64(newResult.Time.UnixNano()-prevResult.Time.UnixNano()) / 1000000000
+ elapsedTimeInSecs :=
float64(newResult.Time.UnixMilli()-prevResult.Time.UnixMilli()) / 1000
Review Comment:
Same comment here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]