-
Notifications
You must be signed in to change notification settings - Fork 36
Clarify documentation about the interaction of recordError and setStatus #167
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
Comments
Thanks for bringing this up! It's a mixture of 3 and 4. Generally, recorded errors are not related to a span's status, meaning the status has to be manually set and is not automatically derived from whether a span recorded any errors. Setting a status is very much explicit and dependent on the use-case. Here's the OTel semantic convention around setting the span status for HTTP spans for example:
https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#status We followed this principle when we designed the span status API for Swift Distributed Tracing. You can also see this in Hummingbird's // ...
catch {
if let endpointPath = context.endpointPath {
span.operationName = endpointPath
}
let statusCode = (error as? HTTPResponseError)?.status.code ?? 500
span.attributes["http.status_code"] = statusCode
if 500..<600 ~= statusCode {
span.setStatus(.init(code: .error))
}
span.recordError(error)
span.end()
throw error
} |
This is great, thanks @slashmo! Let's use this issue to track adding much of your explanation into the docs. |
Currently the docs aren't prescriptive enough, which can make switching between tracing backends more difficult.
For example, does
recordError
imply:setStatus
setStatus
was called withOK
setStatus
is also called withError
)The text was updated successfully, but these errors were encountered: