[][src]Function xi_trace::trace_payload

pub fn trace_payload<S, C, P>(name: S, categories: C, payload: P) where
    S: Into<StrCow>,
    C: Into<CategoriesT>,
    P: Into<TracePayloadT>, 

Create an instantaneous sample with a payload. The type the payload conforms to is currently determined by the feature this library is compiled with. By default, the type is string-like just like name. If compiled with the json_payload then a serde_json::Value is expected and the library acquires a dependency on the serde_json crate.

Performance

A static string has the lowest overhead as no copies are necessary, roughly equivalent performance to a regular trace. A string that needs to be copied first can make it ~1.7x slower than a regular trace.

When compiling with json_payload, this is ~2.1x slower than a string that needs to be copied (or ~4.5x slower than a static string)

Arguments

  • name - A string that provides some meaningful name to this sample. Usage of static strings is encouraged for best performance to avoid copies. However, anything that can be converted into a Cow string can be passed as an argument.

  • categories - A static array of static strings that tags the samples in some way.

Examples

xi_trace::trace_payload("something happened", &["rpc", "response"], "a note about this");

With json_payload feature:

This example is not tested
xi_trace::trace_payload("my event", &["rpc", "response"], json!({"key": "value"}));