@@ -34,6 +34,7 @@ type Session struct {
3434 stats struct {
3535 opmap map [string ]* opStats
3636 total atomic2.Int64
37+ fails atomic2.Int64
3738 flush struct {
3839 n uint
3940 nano int64
@@ -116,6 +117,8 @@ func (s *Session) Start(d *Router) {
116117 go func () {
117118 s .Conn .Encode (redis .NewErrorf ("ERR max number of clients reached" ), true )
118119 s .CloseWithError (ErrTooManySessions )
120+ s .incrFails ()
121+ s .flushOpStats (true )
119122 }()
120123 decrSessions ()
121124 return
@@ -125,6 +128,8 @@ func (s *Session) Start(d *Router) {
125128 go func () {
126129 s .Conn .Encode (redis .NewErrorf ("ERR router is not online" ), true )
127130 s .CloseWithError (ErrRouterNotOnline )
131+ s .incrFails ()
132+ s .flushOpStats (true )
128133 }()
129134 decrSessions ()
130135 return
@@ -162,6 +167,7 @@ func (s *Session) loopReader(tasks *RequestChan, d *Router) (err error) {
162167 s .incrOpTotal ()
163168
164169 if tasks .Buffered () > maxPipelineLen {
170+ s .incrFails ()
165171 return ErrTooManyPipelinedRequests
166172 }
167173
@@ -629,6 +635,10 @@ func (s *Session) incrOpTotal() {
629635 s .stats .total .Incr ()
630636}
631637
638+ func (s * Session ) incrFails () {
639+ s .stats .fails .Incr ()
640+ }
641+
632642func (s * Session ) getOpStats (opstr string ) * opStats {
633643 e := s .stats .opmap [opstr ]
634644 if e == nil {
@@ -665,6 +675,7 @@ func (s *Session) flushOpStats(force bool) {
665675 s .stats .flush .nano = nano
666676
667677 incrOpTotal (s .stats .total .Swap (0 ))
678+ incrOpFails (s .stats .fails .Swap (0 ))
668679 for _ , e := range s .stats .opmap {
669680 if e .calls .Int64 () != 0 || e .fails .Int64 () != 0 {
670681 incrOpStats (e )
0 commit comments