@@ -10,9 +10,9 @@ var msgCounters [4]uint64
1010var msgLast [4 ]uint64
1111var msgCurrent [4 ]uint64
1212
13- var httpCounters [8 ]uint64
14- var httpLast [8 ]uint64
15- var httpCurrent [8 ]uint64
13+ var httpCounters [9 ]uint64
14+ var httpLast [9 ]uint64
15+ var httpCurrent [9 ]uint64
1616
1717// A MsgCounters records message counters.
1818type MsgCounters struct {
@@ -55,6 +55,9 @@ type HttpCounters struct {
5555 // StatusServiceUnavailable is the count of http 503 responses.
5656 StatusServiceUnavailable uint64
5757
58+ // StatusTooManyRequests is the count of http 429 responses.
59+ StatusTooManyRequests uint64
60+
5861 // Written is the number of bytes written.
5962 Written uint64
6063
@@ -97,7 +100,8 @@ func ReadHttpCounters(m *HttpCounters) {
97100 m .StatusNotFound = httpCurrent [4 ] - httpLast [4 ]
98101 m .StatusInternalServerError = httpCurrent [5 ] - httpLast [5 ]
99102 m .StatusServiceUnavailable = httpCurrent [6 ] - httpLast [6 ]
100- m .Written = httpCurrent [7 ] - httpLast [7 ]
103+ m .StatusTooManyRequests = httpCurrent [7 ] - httpLast [7 ]
104+ m .Written = httpCurrent [8 ] - httpLast [8 ]
101105
102106 for i := range httpCounters {
103107 httpLast [i ] = httpCurrent [i ]
@@ -159,7 +163,12 @@ func StatusServiceUnavailable() {
159163 atomic .AddUint64 (& httpCounters [6 ], 1 )
160164}
161165
166+ // StatusTooManyRequests increments the http response 429 counter. It is safe for concurrent access.
167+ func StatusTooManyRequests () {
168+ atomic .AddUint64 (& httpCounters [7 ], 1 )
169+ }
170+
162171// Written increments the bytes sent counter by n.
163172func Written (n int64 ) {
164- atomic .AddUint64 (& httpCounters [7 ], uint64 (n )) //nolint:gosec
173+ atomic .AddUint64 (& httpCounters [8 ], uint64 (n )) //nolint:gosec
165174}
0 commit comments