Replies: 5 comments
-
from https://docs.rs/tracing/latest/tracing/attr.instrument.html |
Beta Was this translation helpful? Give feedback.
-
I'm guessing that the issue you're reporting is that you're not seeing any instrumentation of the return value. Is that correct? I believe that |
Beta Was this translation helpful? Give feedback.
-
You can use
|
Beta Was this translation helpful? Give feedback.
-
According to https://docs.rs/tracing/latest/tracing/attr.instrument.html,
sync_return_err return Err and is supposed to print nothing,but it does print:
Here is the more concise code snippet
|
Beta Was this translation helpful? Give feedback.
-
I happen to meet this too. The following code #[tracing::instrument(ret)]
pub fn sync_return_ok() -> Result<i32, ()> {
Ok(42)
}
#[tokio::test]
async fn test_instrument(){
tracing_subscriber::fmt().with_max_level(tracing::Level::TRACE).init();
let _r = sync_return_ok();
} is supposed to print something like this
but it does print:
I found out that if I combine err and ret, it works as expected #[tracing::instrument(err,ret)]
pub fn sync_return_ok() -> Result<i32, i32> {
Ok(63)
}
#[tracing::instrument(err,ret)]
pub fn sync_return_err() -> Result<i32, i32> {
Err(42)
}
#[tokio::test]
async fn test_instrument(){
tracing_subscriber::fmt().with_max_level(tracing::Level::TRACE).init();
let _ = sync_return_ok();
let _ = sync_return_err();
} This prints
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Report
Version
Platform
Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101 arm64
Description
#[tracing::instrument(level="debug", ret, skip_all)]
pub async fn async_return_ok() -> Result<()> {
Ok(())
}
#[tracing::instrument(level="debug", ret, skip_all)]
pub fn sync_return_ok() -> Result<()> {
Ok(())
}
#[tracing::instrument(level="debug", ret, skip_all)]
pub async fn async_return_err() -> Result<()> {
anyhow::bail!("err")
}
#[tracing::instrument(level="debug", ret, skip_all)]
pub fn sync_return_err() -> Result<()> {
anyhow::bail!("err")
}
#[tokio::test]
async fn test_instrument() -> Result<()> {
tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).init();
let _r = async_return_ok().await;
let _r = async_return_err().await;
let _r = sync_return_ok();
let _r = sync_return_err();
Ok(())
}
Beta Was this translation helpful? Give feedback.
All reactions