Skip to content
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

Feature Request: Integration with TracingError #479

Open
dignifiedquire opened this issue Feb 20, 2025 · 2 comments
Open

Feature Request: Integration with TracingError #479

dignifiedquire opened this issue Feb 20, 2025 · 2 comments

Comments

@dignifiedquire
Copy link

When using tracing in a larger application using tracing-error is quite helpful. It woul be great to have an option to allow capturing a tracing_error::SpanTrace similar to how backtrace capturing works, as part of the generated macro.

I'd be happy to write up a PR, but wanted to get some feedback on this first

#[derive(Debug, Snafu)]
pub enum CoolError {
     A {
       bactrace: Option<Backtrace>,
       // Auto detected
       span_trace: SpanTrace,
     }
     B {
       #[snafu(span_trace)] // manual annotation
       my_cool_span_trace: SpanTrace,
     }
}


// Access through sth like extending the ErrorsCompat trait
pub trait ErrorsCompat {
  // make the dependency fully dependent on the feature flag
  #[cfg(feature = "tracing-error")]
  fn span_trace(&self) -> Option<&SpanTrace> {
    None
  }
}
@shepmaster
Copy link
Owner

You can do this today by implementing GenerateImplicitData.

I think this comment is close.

@dignifiedquire
Copy link
Author

Thanks for the quick response, while that works nicely to generate, it does not give me a way to access the trace in a generic fashion as far as I can tell unfortunately. I am working on a reporting like structure, (that works on stable rust..) and managed to get the backtraces extracted from different error types, thanks to the ErrorCompat::backtrace functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants