Skip to main content

traceable

Attribute Macro traceable 

Source
#[traceable]
Expand description

Marks a fn or async fn as a candidate for tracing.

Every call checks a per-function bitmask before creating any span. A disabled trace site has the cost of one atomic load.

Enable it at runtime through a opentelemetry_traceable::instrumentation::Instrumentation.

The registry key used to enable a function defaults to module_path!() + "::" + fn_name, or the name argument if given. Note: two methods with the same name in the same module share a key unless name is used to distinguish them.

#[traceable]
fn process() { }

#[traceable(name = "kafka.fetch")]
async fn fetch() { }

#[traceable(fields("component" = "proxy", request_id = id))]
async fn handle(id: String) { }