Instrumentation: Handle context.Canceled (#75867)
Ref #68480 Co-authored-by: Giuseppe Guerra <giuseppe.guerra@grafana.com>
This commit is contained in:
co-authored by
Giuseppe Guerra
parent
aee8c91ac8
commit
90631360eb
@@ -133,6 +133,17 @@ func TooManyRequests(msgID string, opts ...BaseOpt) Base {
|
||||
return NewBase(StatusTooManyRequests, msgID, opts...)
|
||||
}
|
||||
|
||||
// ClientClosedRequest initializes a new [Base] error with reason StatusClientClosedRequest
|
||||
// that is used to construct [Error]. The msgID is passed to the caller
|
||||
// to serve as the base for user facing error messages.
|
||||
//
|
||||
// msgID should be structured as component.errorBrief, for example
|
||||
//
|
||||
// plugin.requestCanceled
|
||||
func ClientClosedRequest(msgID string, opts ...BaseOpt) Base {
|
||||
return NewBase(StatusClientClosedRequest, msgID, opts...)
|
||||
}
|
||||
|
||||
// NotImplemented initializes a new [Base] error with reason StatusNotImplemented
|
||||
// that is used to construct [Error]. The msgID is passed to the caller
|
||||
// to serve as the base for user facing error messages.
|
||||
|
||||
@@ -28,6 +28,13 @@ const (
|
||||
// parameters or payload for the request.
|
||||
// HTTP status code 400.
|
||||
StatusBadRequest CoreStatus = "Bad request"
|
||||
// StatusClientClosedRequest means that a client closes the connection
|
||||
// while the server is processing the request.
|
||||
//
|
||||
// This is a non-standard HTTP status code introduced by nginx, see
|
||||
// https://httpstatus.in/499/ for more information.
|
||||
// HTTP status code 499.
|
||||
StatusClientClosedRequest CoreStatus = "Client closed request"
|
||||
// StatusValidationFailed means that the server was able to parse
|
||||
// the payload for the request but it failed one or more validation
|
||||
// checks.
|
||||
@@ -57,6 +64,11 @@ const (
|
||||
StatusGatewayTimeout CoreStatus = "Gateway timeout"
|
||||
)
|
||||
|
||||
// HTTPStatusClientClosedRequest A non-standard status code introduced by nginx
|
||||
// for the case when a client closes the connection while nginx is processing
|
||||
// the request. See https://httpstatus.in/499/ for more information.
|
||||
const HTTPStatusClientClosedRequest = 499
|
||||
|
||||
// StatusReason allows for wrapping of CoreStatus.
|
||||
type StatusReason interface {
|
||||
Status() CoreStatus
|
||||
@@ -84,6 +96,8 @@ func (s CoreStatus) HTTPStatus() int {
|
||||
return http.StatusTooManyRequests
|
||||
case StatusBadRequest, StatusValidationFailed:
|
||||
return http.StatusBadRequest
|
||||
case StatusClientClosedRequest:
|
||||
return HTTPStatusClientClosedRequest
|
||||
case StatusNotImplemented:
|
||||
return http.StatusNotImplemented
|
||||
case StatusBadGateway:
|
||||
|
||||
Reference in New Issue
Block a user