Skip to main content

trace

Macro trace 

Source
trace!() { /* proc-macro */ }
Expand description

Emits a trace-level event.

An optional first argument can provide a typed error. The error must implement std::error::Error + 'static or dereference to that trait. The OpenTelemetry layer records its message as exception.message and its sources as exception.stacktrace.

The event name is required and must be a string literal. When an error is provided, optional target: and parent: arguments go between the error and name, in that order. Without an error, they precede the name. Attributes follow the name and must use a registered field name and a value implementing RecordAttribute. Append #[nonstandard] to a field value to permit an unregistered name while retaining its canonical encoding. Tracing format specifiers and trailing commas are not supported.

The name is recorded as tracing’s message field, which the OpenTelemetry tracing layer uses as the event name.

use miden_node_tracing::trace;

trace!(target: "node", "block.received", block.number = 42_u32);

let source = std::io::Error::other("invalid block");
trace!(&source, "block.rejected", block.number = 42_u32);