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