-
-
Notifications
You must be signed in to change notification settings - Fork 167
Open
Labels
Description
Problem Statement
When attaching an anyhow as a tracing field, we don't use the Backtrace from it, while it would be more valuable to use it.
As an example:
capture_anyhow(&e);
tracing::error!(
error = e.into_boxed_dyn_error(),
"error doing something"
);
The stacktrace obtained with capture_anyhow
will be up to the place where the error was first created.
Instead, the tracing backtrace will just indicate where the call to tracing was made which is way less useful.
This might be an improvement we can make in other places too.
Solution Brainstorm
We should still be able to retrieve the Backtrace
even after we cast to boxed dyn error.
From the anyhow docs:
let boxed_dyn_error = anyhow_error.into_boxed_dyn_error();
assert!(std::error::request_ref::<Backtrace>(&*boxed_dyn_error).is_some()); // has Backtrace
Create a special case to check if the Backtrace
is available and use that one instead of thread::current_stacktrace()
.
bbigras