tracing-instrument-mock

Crates.iotracing-instrument-mock
lib.rstracing-instrument-mock
version0.1.0
created_at2025-11-26 16:23:25.503432+00
updated_at2025-11-26 16:23:25.503432+00
descriptionA mock of the `tracing::instrument` proc macro that does nothing and can replace the `tracing::instrument` macro when running with code coverage enabled.
homepage
repositoryhttps://github.com/famedly/tracing-instrument-mock
max_upload_size
id1951720
size29,875
Famedly Bot (famedly-bot)

documentation

https://docs.rs/tracing-instrument-mock

README

Tracing Instrument Mock

rust workflow status docker workflow status docs main

The tracing::instrument proc macro breaks the code coverage. There is an open issue about it. While there's no solution for this issue, a workaround is to disable the instrument macro when tests with code coverage are run. his crate is just a mock of the tracing::instrument macro that does nothing and can replace the tracing::instrument macro when running with code coverage enabled.

You can select which version of the macro to use using the coverage configuration flag:

#[cfg(not(coverage))]
pub use tracing::instrument;
#[cfg(coverage)]
pub use tracing_instrument_mock::instrument;

Then, when instrumenting functions you can simply do

#[instrument]
fn my_function() {
  println!("Hello, world!");
}

Lints

cargo clippy --workspace --all-targets

and this in your IDE:

cargo clippy --workspace --all-targets --message-format=json

Pre-commit usage

  1. If not installed, install with your package manager, or pip install --user pre-commit
  2. Run pre-commit autoupdate to update the pre-commit config to use the newest template
  3. Run pre-commit install to install the pre-commit hooks to your local environment
Commit count: 0

cargo fmt