From 6c90c68d1bd8246f8078d2f1891a9396f848e51b Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Mon, 12 Sep 2022 09:10:34 +0100 Subject: [PATCH] attributes: Improve output for #[instrument(ret)] This ensures that events generated by this instrumentation have a useful name for consumption in common OpenTelemetry tracing tools. --- tracing-attributes/src/expand.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tracing-attributes/src/expand.rs b/tracing-attributes/src/expand.rs index f9f5cdc860..ca22b2d09a 100644 --- a/tracing-attributes/src/expand.rs +++ b/tracing-attributes/src/expand.rs @@ -243,13 +243,13 @@ fn gen_block( let ret_event = match args.ret_mode { Some(FormatMode::Display) => Some(quote!( - tracing::event!(target: #target, #level, return = %x) + tracing::event!(target: #target, #level, { return = %x }, "{}", x) )), Some(FormatMode::Default) | Some(FormatMode::Debug) => Some(quote!( - tracing::event!(target: #target, #level, return = ?x) + tracing::event!(target: #target, #level, { return = ?x }, "{}", x) )), Some(FormatMode::Raw) => Some(quote!( - tracing::event!(target: #target, #level, return = x) + tracing::event!(target: #target, #level, { return = x }, "{}", x) )), _ => None, };