-
Notifications
You must be signed in to change notification settings - Fork 844
Closed
Labels
crate/attributesRelated to the `tracing-attributes` crateRelated to the `tracing-attributes` cratehelp wantedExtra attention is neededExtra attention is neededkind/bugSomething isn't workingSomething isn't working
Description
Bug Report
async_trait (as re-exported by tonic) and instrument do not work as expected together. Instrumented async trait fns enter then immediately exit and drop their span, while top-level async functions work as expected.
Minimal reproduction with checked-in expanded macro-generated code at https://github.com/inanna-malick/tracing-async-trait-bug-repro
This is a cross-project bug, let me know if it's best posted elsewhere.
Version
│ │ │ │ └── tracing v0.1.9
│ │ │ │ ├── tracing-attributes v0.1.4
│ │ │ │ └── tracing-core v0.1.7
│ │ │ │ └── tracing v0.1.9 (*)
│ │ │ └── tracing-core v0.1.7 (*)
│ │ │ └── tracing v0.1.9 (*)
│ │ └── tracing v0.1.9 (*)
│ └── tracing v0.1.9 (*)
├── tracing v0.1.9 (*)
├── tracing-attributes v0.1.4 (*)
├── tracing-core v0.1.7 (*)
├── tracing-futures v0.1.0
│ └── tracing v0.1.9 (*)
└── tracing-subscriber v0.1.5
├── tracing-core v0.1.7 (*)
└── tracing-log v0.1.0
└── tracing-core v0.1.7 (*)
└── tracing-log v0.1.0 (*)
Platform
Linux pk-thinkpad 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Crates
tracing-attributes, tracing-futures
Description
code output by #[instrument] macro for async trait functions does not use expected code gen pathway for async trait fns.
for
#[tonic::async_trait]
pub trait Foo
where
Self: std::marker::Send,
{
async fn foo(&self) -> ();
}
struct FooImpl;
#[tonic::async_trait]
impl Foo for FooImpl {
#[instrument]
async fn foo(&self) {}
}
#[instrument]
async fn top_level() {}the resulting generated code uses the expected future instrumentation pathway for top_level
tracing_futures::Instrument::instrument(async move { { } },
__tracing_attr_span).awaitbut for the async trait fn foo it generates
fn foo<'life0, 'async_trait>(&'life0 self)
->
::core::pin::Pin<Box<dyn ::core::future::Future<Output = ()> +
::core::marker::Send + 'async_trait>> where
'life0: 'async_trait, Self: 'async_trait {
let __tracing_attr_span = { omitted };
let __tracing_attr_guard = __tracing_attr_span.enter();
{
#[allow(clippy :: used_underscore_binding)]
async fn __foo(_self: &FooImpl) { }
Box::pin(__foo::<>(self))
}
}Metadata
Metadata
Assignees
Labels
crate/attributesRelated to the `tracing-attributes` crateRelated to the `tracing-attributes` cratehelp wantedExtra attention is neededExtra attention is neededkind/bugSomething isn't workingSomething isn't working