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:
parent
f6ccc73151
commit
e1b272ec4c
@ -56,11 +56,13 @@ impl RootSpanBuilder for DefaultRootSpanBuilder {
|
|||||||
|
|
||||||
fn handle_error(span: Span, error: &actix_web::Error) {
|
fn handle_error(span: Span, error: &actix_web::Error) {
|
||||||
let response_error = error.as_response_error();
|
let response_error = error.as_response_error();
|
||||||
span.record(
|
|
||||||
"exception.message",
|
// pre-formatting errors is a workaround for https://github.com/tokio-rs/tracing/issues/1565
|
||||||
&tracing::field::display(response_error),
|
let display = format!("{}", response_error);
|
||||||
);
|
let debug = format!("{:?}", response_error);
|
||||||
span.record("exception.details", &tracing::field::debug(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();
|
let status_code = response_error.status_code();
|
||||||
span.record("http.status_code", &status_code.as_u16());
|
span.record("http.status_code", &status_code.as_u16());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user