instrument_error

Attribute Macro instrument_error 

Source
#[instrument_error]
Expand description

Enables error-level instrumentation for the decorated function.

This attribute macro wraps the function with #[::tracing::instrument(level = "error")], enabling automatic tracing instrumentation at the error level.

§Arguments

  • attr - Additional tracing instrument parameters (optional): target, name, skip, fields, etc.
  • item - The TokenStream representing the function to be instrumented.

§Returns

Returns the expanded TokenStream with tracing instrumentation applied.

§Examples

use tracing;
use instrument_level::*;

#[instrument_error]
async fn test(x: i32, y: i32) -> i32 {
    x + y
}

#[instrument_error(skip_all)]
async fn test_skip_all(x: i32, y: i32) -> i32 {
    x + y
}