Function probe_impl

Source
pub fn probe_impl(tokens: TokenStream) -> TracersResult<TokenStream>
Expand description

Translates what looks to be an explicit call to the associated function corresponding to a probe on a provider trait, into something which at runtime will most efficiently attempt to access the global static instance of the probe and, if it’s enabled, evaluate the args and fire the probe.

It translates something like this:

probe!(MyProvider::myprobe(1, 5, "this is a string", compute_something()));

into:

{
    if let Some(probe) = MyProvider::get_myprobe_probe() {
        if probe.is_enabled() {
            probe.fire((1, 5, "this is a string", compute_something(),)));
        }
    }
}

In particular, note that the probe’s parameters are not evaluated unless the provider initialized successfully and the probe is enabled.