-
Notifications
You must be signed in to change notification settings - Fork 95
feat(ci): lint debug fields in tracing events #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
14dc0c4 to
69d4d52
Compare
| #[derive(Clone, Copy, Debug)] | ||
| struct Wrapped(&'static str); | ||
|
|
||
| fn main() { | ||
| let field = Wrapped("wrapped"); | ||
| info!(field = tracing::field::debug(field), "using the function"); | ||
| info!(field = ?field, "using the sigil"); | ||
| info!(?field, "using shorthand with sigil"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for? just testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this ui/main.rs produces some output when compiled. https://github.com/Manishearth/compiletest-rs then tests the output against ui/main.stderr.
This is to make sure that all the cases that I want the lint to catch are caught.
noot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good! the if_chain is cool :D
…un on custom lints
3f36314 to
1054e81
Compare
## Summary Build images using a Cargo.toml without a default-members entry. ## Background We use cargo-chef to prepare recipes for each individual binary so that only its dependencies are built and cached. PR #664 introduced the `default-members` entry so that cargo invocations by default don't target the lints (as they require a nightly compiler). But this breaks cargo-chef because it leaves default-members intact, leading to cargo compilation issues. ## Changes - Create a special `containerfiles/Cargo.toml` file that is derived from the root `Cargo.toml` but with its `default-members` entry removed - Update `containerfiles/Dockerfile` to run `cargo chef prepare` against `containerfiles/Cargo.toml` - Add a just entry to remove `workspace.default-members` from `Cargo.toml`, format it with `taplo`, and write it to `containerfiles/Cargo.toml` - Add a github job that ensures that `containerfiles/Cargo.toml` is in sync with `Cargo.toml` ## Testing - Docker builds were broken and now work again (verified by building locally and in CI) - Commited a modified `containerfiles/Cargo.toml` and observed the github action trigger ## Related Issues PR causing the build to break: #664
## Summary Build images using a Cargo.toml without a default-members entry. ## Background We use cargo-chef to prepare recipes for each individual binary so that only its dependencies are built and cached. PR astriaorg/astria#664 introduced the `default-members` entry so that cargo invocations by default don't target the lints (as they require a nightly compiler). But this breaks cargo-chef because it leaves default-members intact, leading to cargo compilation issues. ## Changes - Create a special `containerfiles/Cargo.toml` file that is derived from the root `Cargo.toml` but with its `default-members` entry removed - Update `containerfiles/Dockerfile` to run `cargo chef prepare` against `containerfiles/Cargo.toml` - Add a just entry to remove `workspace.default-members` from `Cargo.toml`, format it with `taplo`, and write it to `containerfiles/Cargo.toml` - Add a github job that ensures that `containerfiles/Cargo.toml` is in sync with `Cargo.toml` ## Testing - Docker builds were broken and now work again (verified by building locally and in CI) - Commited a modified `containerfiles/Cargo.toml` and observed the github action trigger ## Related Issues PR causing the build to break: astriaorg/astria#664
## Summary Build images using a Cargo.toml without a default-members entry. ## Background We use cargo-chef to prepare recipes for each individual binary so that only its dependencies are built and cached. PR astriaorg/astria#664 introduced the `default-members` entry so that cargo invocations by default don't target the lints (as they require a nightly compiler). But this breaks cargo-chef because it leaves default-members intact, leading to cargo compilation issues. ## Changes - Create a special `containerfiles/Cargo.toml` file that is derived from the root `Cargo.toml` but with its `default-members` entry removed - Update `containerfiles/Dockerfile` to run `cargo chef prepare` against `containerfiles/Cargo.toml` - Add a just entry to remove `workspace.default-members` from `Cargo.toml`, format it with `taplo`, and write it to `containerfiles/Cargo.toml` - Add a github job that ensures that `containerfiles/Cargo.toml` is in sync with `Cargo.toml` ## Testing - Docker builds were broken and now work again (verified by building locally and in CI) - Commited a modified `containerfiles/Cargo.toml` and observed the github action trigger ## Related Issues PR causing the build to break: astriaorg/astria#664
Summary
Add a custom lint using the
dylinttool to detect and warn about debug-formatted fields in tracing events.Background
Debug-formatted fields in tracing events are bad practice. They are hard to read and parse, and they surface language-specific implementation details that have no place in observability.
The present lint only acts on debug-formatted fields in
tracing::event!macros (which includes macros likeinfo!andwarn!that are implemented in terms of it). Debug-formatted fields in#[instrument]proc macros will be detected in a separate lint.Changes
tracing::event!macrosdefault-membersfield to the virtual workspace so that the lints are exempt from most CI jobs (the lints require a nightly rust)Testing
This patch provides
compiletest-rsmacros that correctly detects debug-formatted fields in event macros and not in instrument-proc-macros.