home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Skip The self Argument When Instrumenting Tracing On A Rust Function

February 2024
Code
```cargo
[dependencies]
tracing = "0.1"
tracing-subscriber = "0.3"
```
use tracing::{Level, event, instrument};

fn main() {
  tracing_subscriber::fmt().with_ansi(false).init();
  let w = Widget{};
  w.instrument_with_self();
  w.instrument_without_self();
}

#[derive(Debug)]
pub struct Widget{}

impl Widget {
  #[instrument]
  pub fn instrument_with_self(&self) {
    event!(Level::INFO, "ping");
  }
  #[instrument(skip(self))]
  pub fn instrument_without_self(&self) {
    event!(Level::INFO, "ping");
  }
}
Results
2024-02-29T00:49:19.740982Z  INFO instrument_with_self{self=Widget}: _active_nvim_run: ping
2024-02-29T00:49:19.741050Z  INFO instrument_without_self: _active_nvim_run: ping
═══ § ═══