@@ -490,37 +490,39 @@ func (f *Handler) reportQueryStats(r *http.Request, source, userID string, query
490
490
}
491
491
}
492
492
493
- // We are unable to use errors.As to compare since body string from the http response is wrapped as an error
494
493
var reason string
495
- errMsg := error .Error ()
496
- if statusCode == http .StatusTooManyRequests {
497
- var resourceExhaustedErr resource.ExhaustedError
498
- if strings .Contains (errMsg , resourceExhaustedErr .Error ()) {
499
- reason = reasonResourceExhausted
500
- } else {
501
- reason = reasonTooManyRequests
502
- }
503
- } else if statusCode == http .StatusRequestEntityTooLarge {
494
+ if statusCode == http .StatusRequestEntityTooLarge {
504
495
reason = reasonResponseBodySizeExceeded
505
- } else if statusCode == http .StatusUnprocessableEntity {
506
- if strings .Contains (errMsg , limitTooManySamples ) {
507
- reason = reasonTooManySamples
508
- } else if strings .Contains (errMsg , limitTimeRangeExceeded ) {
509
- reason = reasonTimeRangeExceeded
510
- } else if strings .Contains (errMsg , limitSeriesFetched ) {
511
- reason = reasonSeriesFetched
512
- } else if strings .Contains (errMsg , limitChunksFetched ) {
513
- reason = reasonChunksFetched
514
- } else if strings .Contains (errMsg , limitChunkBytesFetched ) {
515
- reason = reasonChunkBytesFetched
516
- } else if strings .Contains (errMsg , limitDataBytesFetched ) {
517
- reason = reasonDataBytesFetched
518
- } else if strings .Contains (errMsg , limitSeriesStoreGateway ) {
519
- reason = reasonSeriesLimitStoreGateway
520
- } else if strings .Contains (errMsg , limitChunksStoreGateway ) {
521
- reason = reasonChunksLimitStoreGateway
522
- } else if strings .Contains (errMsg , limitBytesStoreGateway ) {
523
- reason = reasonBytesLimitStoreGateway
496
+ } else if error != nil {
497
+ // We are unable to use errors.As to compare since body string from the http response is wrapped as an error
498
+ errMsg := error .Error ()
499
+ if statusCode == http .StatusTooManyRequests {
500
+ var resourceExhaustedErr resource.ExhaustedError
501
+ if strings .Contains (errMsg , resourceExhaustedErr .Error ()) {
502
+ reason = reasonResourceExhausted
503
+ } else {
504
+ reason = reasonTooManyRequests
505
+ }
506
+ } else if statusCode == http .StatusUnprocessableEntity {
507
+ if strings .Contains (errMsg , limitTooManySamples ) {
508
+ reason = reasonTooManySamples
509
+ } else if strings .Contains (errMsg , limitTimeRangeExceeded ) {
510
+ reason = reasonTimeRangeExceeded
511
+ } else if strings .Contains (errMsg , limitSeriesFetched ) {
512
+ reason = reasonSeriesFetched
513
+ } else if strings .Contains (errMsg , limitChunksFetched ) {
514
+ reason = reasonChunksFetched
515
+ } else if strings .Contains (errMsg , limitChunkBytesFetched ) {
516
+ reason = reasonChunkBytesFetched
517
+ } else if strings .Contains (errMsg , limitDataBytesFetched ) {
518
+ reason = reasonDataBytesFetched
519
+ } else if strings .Contains (errMsg , limitSeriesStoreGateway ) {
520
+ reason = reasonSeriesLimitStoreGateway
521
+ } else if strings .Contains (errMsg , limitChunksStoreGateway ) {
522
+ reason = reasonChunksLimitStoreGateway
523
+ } else if strings .Contains (errMsg , limitBytesStoreGateway ) {
524
+ reason = reasonBytesLimitStoreGateway
525
+ }
524
526
}
525
527
}
526
528
if len (reason ) > 0 {
0 commit comments