Error Flagging with Status Codes (#966)

* StatusSource definition

* Update HTTP status code mapping

* Remove span status

* Apply feedback.

* Remove unused link.

* markdownlint

* spelling

Co-authored-by: Carlos Alberto Cortez <calberto.cortez@gmail.com>
This commit is contained in:
Ted Young 2020-09-24 11:24:31 -07:00 committed by GitHub
parent 5874138953
commit bbd284a9d9
1 changed files with 6 additions and 27 deletions

View File

@ -37,37 +37,16 @@ default span name.
## Status
Implementations MUST set the [span status](../api.md#status) if the HTTP communication failed
or an HTTP error status code is returned (e.g. above 3xx).
[Span Status](../api.md#status) MUST be left unset if HTTP status code was in the
1xx, 2xx or 3xx ranges, unless there was another error (e.g., network error receiving
the response body; or 3xx codes with max redirects exceeded), in which case status
MUST be set to `Error`.
In the case of an HTTP redirect, the request should normally be considered successful,
unless the client aborts following redirects due to hitting some limit (redirect loop).
If following a (chain of) redirect(s) successfully, the status should be set according to the result of the final HTTP request.
For HTTP status codes in the 4xx and 5xx ranges, as well as any other code the client
failed to interpret, status MUST be set to `Error`.
Don't set the span status description if the reason can be inferred from `http.status_code`.
| HTTP code | Span status code |
|-------------------------|-----------------------|
| 100...299 | `Ok` |
| 3xx redirect codes | `DeadlineExceeded` in case of loop (see above) [1], otherwise `Ok` |
| 401 Unauthorized ⚠ | `Unauthenticated` ⚠ (Unauthorized actually means unauthenticated according to [RFC 7235][rfc-unauthorized]) |
| 403 Forbidden | `PermissionDenied` |
| 404 Not Found | `NotFound` |
| 429 Too Many Requests | `ResourceExhausted` |
| 499 Client Closed | `Cancelled` (Not an official HTTP status code, defined by [NGINX][nginx-http-499]) |
| Other 4xx code | `InvalidArgument` [1] |
| 501 Not Implemented | `Unimplemented` |
| 503 Service Unavailable | `Unavailable` |
| 504 Gateway Timeout | `DeadlineExceeded` |
| Other 5xx code | `Internal` [1] |
| Any status code the client fails to interpret (e.g., 093 or 573) | `Unknown` |
Note that the items marked with [1] are different from the mapping defined in the [OpenCensus semantic conventions][oc-http-status].
[oc-http-status]: https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/HTTP.md#mapping-from-http-status-codes-to-trace-status-codes
[rfc-unauthorized]: https://tools.ietf.org/html/rfc7235#section-3.1
[nginx-http-499]: https://httpstatuses.com/499
## Common Attributes
<!-- semconv http -->