You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to cut down on log noise due to transient errors that are automatically retried.
Scenario: I have a set of functions that return Result<_, Error> annotated with tracing::instrument(err). I would like the generated span's level to depend on the exact Error.
Here's a small illustration of the setup.
#[derive(Debug)]pubenumError{// I'd like this to log at Level::ERROR.Fatal,// I'd like this to log at level::DEBUG,Transient,}#[tracing::instrument(err(Debug))]fnrun(result:Result<(),Error>) -> Result<(),Error>{
result
}fnmain(){
tracing_subscriber::fmt().init();let _ = run(Ok(()));let _ = run(Err(Error::Fatal));let _ = run(Err(Error::Transient));}
How can I accomplish this? I'd prefer not to abandon tracing::instrument and manage spans by hand, as it would end up being a lot of boilerplate across many functions that have the same behavior.
I was imagining such a thing would take the form of
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to cut down on log noise due to transient errors that are automatically retried.
Scenario: I have a set of functions that return
Result<_, Error>
annotated withtracing::instrument(err)
. I would like the generated span's level to depend on the exactError
.Here's a small illustration of the setup.
How can I accomplish this? I'd prefer not to abandon
tracing::instrument
and manage spans by hand, as it would end up being a lot of boilerplate across many functions that have the same behavior.I was imagining such a thing would take the form of
... but I wanted to see if there was a better way before suggesting features.
Beta Was this translation helpful? Give feedback.
All reactions