Skip to content

Commit ce1d96a

Browse files
committed
Add warn logs for failureRate
1 parent ef43d5e commit ce1d96a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

monitorData.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12+
"github.com/ServiceComb/go-chassis/core/lager"
1213
"github.com/rcrowley/go-metrics"
1314
)
1415

@@ -126,10 +127,11 @@ func (monitorData *MonitorData) appendInterfaceInfo(name string, i interface{})
126127
if totalErrorCount == 0 {
127128
interfaceInfo.FailureRate = 0
128129
} else {
129-
failureRate, errr := strconv.ParseFloat(fmt.Sprintf("%.3f", float64(totalErrorCount)/float64(interfaceInfo.Total)), 64)
130-
if errr == nil && failureRate > 0 {
130+
failureRate, err := strconv.ParseFloat(fmt.Sprintf("%.3f", float64(totalErrorCount)/float64(interfaceInfo.Total)), 64)
131+
if err == nil && failureRate > 0 {
131132
interfaceInfo.FailureRate = failureRate
132133
} else {
134+
lager.Logger.Warnf("Error in calculating the failureRate %v, default value(0) is assigned to failureRate", failureRate)
133135
interfaceInfo.FailureRate = 0
134136
}
135137
}

0 commit comments

Comments
 (0)