#[trace]
Expand description
This attribute can be applied to functions and async functions to instrument them.
By default, when applied to a function, it will trace function entry and function exit.
If applied to async fn
, it will report creation, drop and poll spans of the respective Future.
This macro accepts following parameters:
comment=S
— optional string, which will be saved in the metadata for trace interpretation tool to inspectnoenter_fn
— in case used on sync fn, it will disable function entry tracing. If instrumented fn isasync
, Future creation will not be reported.noexit_fn
— same asnoenter_fn
, but exit or Future drop will not be reported. This will break the current mechanism of Future lifetime tracingnoenter_poll
— applicable toasync fn
. Disables tracing of Futurepoll(..)
entry.noexit_poll
— same asnoenter_poll
, but forpoll
exit.skip=N
— Report function entry and exit (or Future creation/drop) only each Nth time. Can be used to releif the transport bandwidth requirement.skip_poll=N
— same, but for poll function.
Please note, that current implementation handles skip and skip_poll independent, so specifying
skip will likely break Future lifetime tracing.
Example:
ⓘ
#[utrace::trace(comment="This is my comment", noenter_fn, noexit_poll)]
async fn my_future() {
....
}