@@ -34,6 +34,7 @@ type Session struct {
34
34
stats struct {
35
35
opmap map [string ]* opStats
36
36
total atomic2.Int64
37
+ fails atomic2.Int64
37
38
flush struct {
38
39
n uint
39
40
nano int64
@@ -116,6 +117,8 @@ func (s *Session) Start(d *Router) {
116
117
go func () {
117
118
s .Conn .Encode (redis .NewErrorf ("ERR max number of clients reached" ), true )
118
119
s .CloseWithError (ErrTooManySessions )
120
+ s .incrFails ()
121
+ s .flushOpStats (true )
119
122
}()
120
123
decrSessions ()
121
124
return
@@ -125,6 +128,8 @@ func (s *Session) Start(d *Router) {
125
128
go func () {
126
129
s .Conn .Encode (redis .NewErrorf ("ERR router is not online" ), true )
127
130
s .CloseWithError (ErrRouterNotOnline )
131
+ s .incrFails ()
132
+ s .flushOpStats (true )
128
133
}()
129
134
decrSessions ()
130
135
return
@@ -162,6 +167,7 @@ func (s *Session) loopReader(tasks *RequestChan, d *Router) (err error) {
162
167
s .incrOpTotal ()
163
168
164
169
if tasks .Buffered () > maxPipelineLen {
170
+ s .incrFails ()
165
171
return ErrTooManyPipelinedRequests
166
172
}
167
173
@@ -629,6 +635,10 @@ func (s *Session) incrOpTotal() {
629
635
s .stats .total .Incr ()
630
636
}
631
637
638
+ func (s * Session ) incrFails () {
639
+ s .stats .fails .Incr ()
640
+ }
641
+
632
642
func (s * Session ) getOpStats (opstr string ) * opStats {
633
643
e := s .stats .opmap [opstr ]
634
644
if e == nil {
@@ -665,6 +675,7 @@ func (s *Session) flushOpStats(force bool) {
665
675
s .stats .flush .nano = nano
666
676
667
677
incrOpTotal (s .stats .total .Swap (0 ))
678
+ incrOpFails (s .stats .fails .Swap (0 ))
668
679
for _ , e := range s .stats .opmap {
669
680
if e .calls .Int64 () != 0 || e .fails .Int64 () != 0 {
670
681
incrOpStats (e )
0 commit comments