|
|
@ -48,20 +48,15 @@ func (s *SheddingStat) IncrementDrop() {
|
|
|
|
atomic.AddInt64(&s.drop, 1)
|
|
|
|
atomic.AddInt64(&s.drop, 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *SheddingStat) reset() snapshot {
|
|
|
|
func (s *SheddingStat) loop(c <-chan time.Time) {
|
|
|
|
return snapshot{
|
|
|
|
for range c {
|
|
|
|
Total: atomic.SwapInt64(&s.total, 0),
|
|
|
|
st := s.reset()
|
|
|
|
Pass: atomic.SwapInt64(&s.pass, 0),
|
|
|
|
|
|
|
|
Drop: atomic.SwapInt64(&s.drop, 0),
|
|
|
|
if !logEnabled.True() {
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *SheddingStat) run() {
|
|
|
|
|
|
|
|
ticker := time.NewTicker(time.Minute)
|
|
|
|
|
|
|
|
defer ticker.Stop()
|
|
|
|
|
|
|
|
for range ticker.C {
|
|
|
|
|
|
|
|
c := stat.CpuUsage()
|
|
|
|
c := stat.CpuUsage()
|
|
|
|
st := s.reset()
|
|
|
|
|
|
|
|
if st.Drop == 0 {
|
|
|
|
if st.Drop == 0 {
|
|
|
|
logx.Statf("(%s) shedding_stat [1m], cpu: %d, total: %d, pass: %d, drop: %d",
|
|
|
|
logx.Statf("(%s) shedding_stat [1m], cpu: %d, total: %d, pass: %d, drop: %d",
|
|
|
|
s.name, c, st.Total, st.Pass, st.Drop)
|
|
|
|
s.name, c, st.Total, st.Pass, st.Drop)
|
|
|
@ -71,3 +66,18 @@ func (s *SheddingStat) run() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (s *SheddingStat) reset() snapshot {
|
|
|
|
|
|
|
|
return snapshot{
|
|
|
|
|
|
|
|
Total: atomic.SwapInt64(&s.total, 0),
|
|
|
|
|
|
|
|
Pass: atomic.SwapInt64(&s.pass, 0),
|
|
|
|
|
|
|
|
Drop: atomic.SwapInt64(&s.drop, 0),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (s *SheddingStat) run() {
|
|
|
|
|
|
|
|
ticker := time.NewTicker(time.Minute)
|
|
|
|
|
|
|
|
defer ticker.Stop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.loop(ticker.C)
|
|
|
|
|
|
|
|
}
|
|
|
|