Fix Data Race in Metrics
This commit is contained in:
parent
0550a71244
commit
d230a1b629
|
@ -151,11 +151,13 @@ func (mh *monitorHistory) Months() []float64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mh *monitorHistory) Report(w *bufio.Writer) {
|
func (mh *monitorHistory) Report(w *bufio.Writer) {
|
||||||
|
mh.lock.Lock()
|
||||||
fmt.Fprintln(w, "Minutes:", reportLine(mh.monitorType, mh.perMinutePerHour[:]))
|
fmt.Fprintln(w, "Minutes:", reportLine(mh.monitorType, mh.perMinutePerHour[:]))
|
||||||
fmt.Fprintln(w, "Hours: ", reportLine(mh.monitorType, mh.perHourForDay[:]))
|
fmt.Fprintln(w, "Hours: ", reportLine(mh.monitorType, mh.perHourForDay[:]))
|
||||||
fmt.Fprintln(w, "Days: ", reportLine(mh.monitorType, mh.perDayForWeek[:]))
|
fmt.Fprintln(w, "Days: ", reportLine(mh.monitorType, mh.perDayForWeek[:]))
|
||||||
fmt.Fprintln(w, "Weeks: ", reportLine(mh.monitorType, mh.perWeekForMonth[:]))
|
fmt.Fprintln(w, "Weeks: ", reportLine(mh.monitorType, mh.perWeekForMonth[:]))
|
||||||
fmt.Fprintln(w, "Months: ", reportLine(mh.monitorType, mh.perMonthForYear[:]))
|
fmt.Fprintln(w, "Months: ", reportLine(mh.monitorType, mh.perMonthForYear[:]))
|
||||||
|
mh.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportLine(t MonitorType, array []float64) string {
|
func reportLine(t MonitorType, array []float64) string {
|
||||||
|
|
Loading…
Reference in New Issue