| Crates.io | tracing-instrument-mock |
| lib.rs | tracing-instrument-mock |
| version | 0.1.0 |
| created_at | 2025-11-26 16:23:25.503432+00 |
| updated_at | 2025-11-26 16:23:25.503432+00 |
| description | A mock of the `tracing::instrument` proc macro that does nothing and can replace the `tracing::instrument` macro when running with code coverage enabled. |
| homepage | |
| repository | https://github.com/famedly/tracing-instrument-mock |
| max_upload_size | |
| id | 1951720 |
| size | 29,875 |
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!");
}
cargo clippy --workspace --all-targets
and this in your IDE:
cargo clippy --workspace --all-targets --message-format=json
pip install --user pre-commitpre-commit autoupdate to update the pre-commit config to use the newest templatepre-commit install to install the pre-commit hooks to your local environment