Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP span status: use SHOULD instead of MUST for errors #1167

Merged
merged 8 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .chloggen/1167.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
change_type: bug_fix
component: http
note: "Relax requirement on when to set HTTP span status to Error from `MUST` to `SHOULD`."
issues: [1167, 1003]
20 changes: 16 additions & 4 deletions docs/http/http-spans.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,31 @@ Instrumentation MUST NOT default to using URI path as a `{target}`.
the response body; or 3xx codes with max redirects exceeded), in which case status
MUST be set to `Error`.

> **Note:**
>
> The classification of an HTTP status code as an error depends on the context.
> For example, a 404 "Not Found" status code indicates an error if the application
> expected the resource to be available. However, it is not an error when the
> application is simply checking whether the resource exists.
>
> Instrumentations that have additional context about a specific request MAY use
> this context to set the span status more precisely.
> Instrumentations that don't have any additional context MUST follow the
> guidelines in this section.

For HTTP status codes in the 4xx range span status MUST be left unset in case of `SpanKind.SERVER`
and MUST be set to `Error` in case of `SpanKind.CLIENT`.
and SHOULD be set to `Error` in case of `SpanKind.CLIENT`.
lmolkova marked this conversation as resolved.
Show resolved Hide resolved

For HTTP status codes in the 5xx range, as well as any other code the client
failed to interpret, span status MUST be set to `Error`.
failed to interpret, span status SHOULD be set to `Error`.

Don't set the span status description if the reason can be inferred from `http.response.status_code`.

HTTP request may fail if it was cancelled or an error occurred preventing
the client or server from sending/receiving the request/response fully.

When instrumentation detects such errors it MUST set span status to `Error`
and MUST set the `error.type` attribute.
When instrumentation detects such errors it SHOULD set span status to `Error`
and SHOULD set the `error.type` attribute.

## HTTP client

Expand Down
Loading