1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-02-23 19:03:03 +01:00

Tracing error workaround (#38)

* Allow root_span to wrap the full middlware chain, not just the output future

* Build error string outside of span.record

This is a workaround for https://github.com/tokio-rs/tracing/issues/1565

* Reference issue being worked-around as comment
This commit is contained in:
Riley 2021-09-21 03:33:32 -05:00 committed by GitHub
parent f6ccc73151
commit e1b272ec4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,11 +56,13 @@ impl RootSpanBuilder for DefaultRootSpanBuilder {
fn handle_error(span: Span, error: &actix_web::Error) {
let response_error = error.as_response_error();
span.record(
"exception.message",
&tracing::field::display(response_error),
);
span.record("exception.details", &tracing::field::debug(response_error));
// pre-formatting errors is a workaround for https://github.com/tokio-rs/tracing/issues/1565
let display = format!("{}", response_error);
let debug = format!("{:?}", response_error);
span.record("exception.message", &tracing::field::display(display));
span.record("exception.details", &tracing::field::display(debug));
let status_code = response_error.status_code();
span.record("http.status_code", &status_code.as_u16());