Attribute Macro trace

Source
#[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 inspect
  • noenter_fn — in case used on sync fn, it will disable function entry tracing. If instrumented fn is async, Future creation will not be reported.
  • noexit_fn — same as noenter_fn, but exit or Future drop will not be reported. This will break the current mechanism of Future lifetime tracing
  • noenter_poll — applicable to async fn. Disables tracing of Future poll(..) entry.
  • noexit_poll — same as noenter_poll, but for poll 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() {
    ....
}