|
|
@ -3,6 +3,7 @@ package metric |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"math" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
|
"sync/atomic" |
|
|
|
"sync/atomic" |
|
|
@ -42,7 +43,7 @@ func (p *Percent) Get(returnString bool) interface{} { |
|
|
|
if returnString { |
|
|
|
if returnString { |
|
|
|
return "null" |
|
|
|
return "null" |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return int64(^uint64(0) >> 1) // int64_max
|
|
|
|
return math.MaxFloat64 |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dividend := atomic.LoadUint64(&p.Dividend) |
|
|
|
dividend := atomic.LoadUint64(&p.Dividend) |
|
|
@ -225,7 +226,10 @@ func (m *Metric) GetAvgDelay() interface{} { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *Metric) GetAvgDelayFloat64() float64 { |
|
|
|
func (m *Metric) GetAvgDelayFloat64() float64 { |
|
|
|
return float64(m.AvgDelay.Get(false).(int64)) |
|
|
|
if avgDelay, ok := m.AvgDelay.Get(false).(float64); ok { |
|
|
|
|
|
|
|
return avgDelay |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return math.MaxFloat64 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *Metric) AddNetworkFlow(dbSyncerID int, val uint64) { |
|
|
|
func (m *Metric) AddNetworkFlow(dbSyncerID int, val uint64) { |
|
|
|