#tracing #projects #instrumentation #add #instrument #thousands #logging

app clippy-tracing

A tool to add, remove and check for tracing::instrument in large projects where it is infeasible to manually add it to thousands of functions

9 releases (breaking)

0.7.0 Oct 13, 2023
0.6.0 Sep 1, 2023
0.5.0 Aug 20, 2023
0.4.0 Aug 17, 2023
0.1.0 Jun 20, 2023

#189 in Procedural macros

Download history 25/week @ 2024-02-19 5/week @ 2024-02-26 5/week @ 2024-03-11 64/week @ 2024-04-01

69 downloads per month

Apache-2.0

23KB
417 lines

clippy-tracing

Crates.io codecov

This is rough tool

A tool to add, remove and check for tracing::instrument in large projects where it is infeasible to manually add it to thousands of functions.

Installation

cargo install clippy-tracing

Usage

This is tested in the readme() integration test.

fn main() {
    println!("Hello World!");
}
fn add(lhs: i32, rhs: i32) -> i32 {
    lhs + rhs
}
#[cfg(tests)]
mod tests {
    fn sub(lhs: i32, rhs: i32) -> i32 {
        lhs - rhs
    }
    #[test]
    fn test_one() {
        assert_eq!(add(1,1), sub(2, 1));
    }
}
clippy-tracing --action check # Missing instrumentation at {path}:9:4.\n
echo $? # 2
clippy-tracing --action fix
echo $? # 0
#[tracing::instrument(level = "trace", skip())]
fn main() {
    println!("Hello World!");
}
#[tracing::instrument(level = "trace", skip(lhs, rhs))]
fn add(lhs: i32, rhs: i32) -> i32 {
    lhs + rhs
}
#[cfg(tests)]
mod tests {
    #[tracing::instrument(level = "trace", skip(lhs, rhs))]
    fn sub(lhs: i32, rhs: i32) -> i32 {
        lhs - rhs
    }
    #[test]
    fn test_one() {
        assert_eq!(add(1,1), sub(2, 1));
    }
}
clippy-tracing --action check
echo $? # 0
clippy-tracing --action strip
echo $? # 0
fn main() {
    println!("Hello World!");
}
fn add(lhs: i32, rhs: i32) -> i32 {
    lhs + rhs
}
#[cfg(tests)]
mod tests {
    fn sub(lhs: i32, rhs: i32) -> i32 {
        lhs - rhs
    }
    #[test]
    fn test_one() {
        assert_eq!(add(1,1), sub(2, 1));
    }
}

log

Supports log_instrument when compiled with the log feature.

Dependencies

~1.8–2.5MB
~46K SLoC