getsentry / getsentry/sentry-rust
Use `anyhow` backtrace if available when creating event out of `tracing` event
- Dominant language
- Rust
- Stars
- 752
- Forks
- 190
- Avg merge
- 1h 21m
- Merged PRs (30d)
- 5
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:
```rust
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:
```rust
let boxed_dyn_error = anyhow_error.into_boxed_dyn_error();
assert!(std::error::request_ref::(&*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()`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.