Skip to main content

span

Attribute Macro span 

Source
#[span]
Expand description

Instrument a method as a telemetry operation span in libxmtp’s single canonical, OTEL-safe form: #[tracing::instrument(err, skip_all, fields(operation = "<prefix>.<fn_name>"))].

err records span status=error on an Err return; skip_all keeps every argument off the span so a per-call id can never leak in and explode trace-attribute cardinality. operation is the single dimension the Collector’s span_metrics connector buckets on. Making this the only writable form guarantees those invariants at compile time — no runtime test.

This is the escape hatch for a namespace without a dedicated attribute; prefer [rpc_span] / [db_span] / [mls_span] where they apply.

#[xmtp_macro::span(prefix = "stream")]
pub async fn subscribe(&self, ..) -> Result<..> { .. }
// → operation = "stream.subscribe"