chore: rebase Redact format mode onto latest upstream#1
Merged
pruthvikar merged 28 commits intomasterfrom Mar 7, 2026
Merged
Conversation
There was only a single case of the new `needless_as_bytes` lint which was triggered and needed to be fixed. There was also a "UI" test in `tracing-attributes` that needed to be updated because the error text has changed (it gives more details of course).
We had some broken link formatting in the `tracing-journald` docs which clippy picked up (the text looked like a link definition, but wasn't meant to be). The incorrect links have now been corrected. They have to link to the `tracing-core` crate because `tracing-journald` doesn't depend on `tracing` directly. Fixes for a broken link in the `tracing-subscriber` main page and correcting the link to `Collect` from `tracing-log` (which also doesn't depend on `tracing` directly) were also included.
… call (tokio-rs#3227) ## Motivation Currently, Span.record_all() is part of the public API and accepts ValueSet as a parameter. However, constructing a ValueSet is both verbose and undocumented, making it not so practical. ## Solution To make recording multiple values easier, we introduce a new macro: record_all!, which wraps the Span.record_all() function. As we don't intend anyone to call Span.record_all() directly, we hide it from the documentation. We reference the new macro from Span.record() doc comment instead. The new record_all! macro supports optional formatting sigils % and ?, ensuring a consistent DevEx with the other value-recording macros. Co-authored-by: Hayden Stainsby <hds@caffeineconcepts.com>
## Motivation I want to use `bevy_reflect` on `no_std` devices. This platform has alloc, but not atomics, so `alloc::sync` is missing. `bevy_relflect` has a hard depency on `tracing`, and I'd like to use tracing on this platform also. Want to use tracing-core on `no_std` devices like rp2040 without hardware atomics ## Solution - Added `portable-atomic-util` as an optional dependency gated behind a new feature, `portable-atomic` to `tracing-core` - When `portable-atomic` is enabled, switched uses of `Arc` and `Weak` away from `alloc::sync` to `portable_atomic_util`. - Added workaround for a lack of support for [unsized coercion](rust-lang/rust#18598) in custom types. I've included a comment linking to this issue explaining the missing functionality. Fixes tokio-rs#3173
…io-rs#3246) This PR expands [`portable-atomic`](https://docs.rs/portable-atomic/) utilisation within Tracing, improving platform support without breaking the existing public API. ## Motivation Since tokio-rs#3199 was merged, it's now possible to bring more tracing crates to atomically challenged platforms through `portable-atomic`. Additionally, CI is not currently setup to ensure this feature behaves as expected (allowing compilation on platforms with incomplete atomic support). ## Solution - Added `portable-atomic` support to: - `tracing` - `tracing-futures` - `tracing-serde` - `tracing-subscriber` - Added `no_std` support to: - `tracing-macros` - `tracing-futures` - Added CI task to catch regressions in `portable-atomic` _and_ `no_std` support. ## Notes - A `critical-section` feature is also added to make CI testing and usage of `tracing`/etc. on atomically challenged platforms simpler. - No additional dependencies are included in this PR, optional or otherwise. Instances of including `portable-atomic` as a dependency only occur when it would have already been included transitively via `tracing-core`'s `portable-atomic-util` dependency. - I checked all instances of replacing `core::sync::atomic` with `portable-atomic` to ensure the public API was unaffected. As such, this is not a breaking change, since it simply adds `portable-atomic` and `critical-section` features.
There was a single case of the new [`clippy::double_ended_iterator_last`] lint which was triggered in `tracing-attributes` and needed to be fixed. There were also a number of cases of incorrectly indented lines, caught in [`clippy::doc_overindented_list_items`]. [`clippy::double_ended_iterator_last`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_ended_iterator_last [`clippy::doc_overindented_list_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items
…rs#3243) There is a report in tokio-rs#3174 that even in release mode, building the regex used to parse `EnvFilter` directives can take a relatively large amount of time (600us). This change replaces the `regex` based parsing of the directives with a state machine implementation that is faster and also easier to reason about. Fixes: tokio-rs#3174
…-rs#3130) * macros: Add test involving raw identifier * macros: Remove 'r#' prefix from raw identifiers in field names
This example demonstrates how to use the `tracing-subscriber` crate's `EnvFilter` type to filter log messages based on their metadata. The example provides a text area where users can input an environment filter string, and displays the log messages that would be captured by that filter.
Update the version of the `matchers` crate to 0.2. This requires also adding a direct dependency on `regex-automata` to enable the `std` feature.
It can be useful to have a TestWriter that does not log to stdout but stderr instead. For example, that allows for potentially easier filtering of tracing output (because the remaining output of, say, cargo test goes to stdout) or to mirror behavior of env_logger, which by default logs to stderr. Introduce the TestWriter::with_stderr() constructor to enable such usage. The default is left unchanged. Co-authored-by: David Barsky <me@davidbarsky.com>
Avoid ambiguities with any user-defined `tracing` modules by globally qualifying types used in the attribute-generated code e.g., `::tracing::Level`.
There are a few warnings when building the docs causing failures on CI. This change fixes those and adds `unsound_local_offset` as an unexpeced cfg.
…-rs#3236) `self` and `other` are references, and the `ptr::eq()` call intends to determine if they designate the same object. Putting them behind another level of reference will always return `false`, as those short-lived references will be compared instead.
## Motivation While configuring tracing-appender, I wanted to specify a weekly log rotation interval. I was unable to do so, as the largest rotation interval was daily. ## Solution Before my introduction of weekly log rotation, rounding the current `OffsetDateTime` was straightforward: we could simply keep the current date and truncate part or all of the time component. However, we cannot simply truncate the time with weekly rotation; the date must now be modified. To round the date, we roll logs at 00:00 UTC on Sunday. This gives us consistent date-times that only change weekly.
Explain that `master` is no longer in use and direct users to `main` for the released crates and `v0.2.x` for the pre-release versions.
This is useful when using `EnvFilter` for multiple identical per-layer filters, as well as with clap and similar libraries that have `Clone` bounds. We generally expect users to be cloning an `EnvFilter` before attaching it to a subscriber, rather than cloning `EnvFilters` that are already attached. Because of this, we reset all the accumulated dynamic state when cloning. This means that some spans and callsites might be missed when an already-attached `EnvFilter` is cloned, but the presence of the dynamic state mean that detaching and attaching `EnvFilter`s to existing subscribers (e.g. with `reload`) already doesn't work very well. This isn't a new class of problem. There was a previous implementation of this in tokio-rs#2398, that shared the dynamic state between all cloned filters behind an `Arc`. I chose not do go for that approach because it causes inconsistencies if the cloned filters are attached to different subscribers. Fixes: tokio-rs#2360
Adds a FormatMode::Redact variant that logs return = "[redacted]" instead of the actual return value when used as ret(Redact). This is useful for endpoints that return large or sensitive data where you want tracing instrumentation but not the value logged. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The error arm was incorrectly logging return = "[redacted]" instead of error = "[redacted]", inconsistent with the Display and Debug modes which both use the error field name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a `latency` argument to `#[instrument]` that automatically records the function's execution time in milliseconds as a span field. Usage: #[instrument(latency)] This eliminates the need for manual timing boilerplate with fields(latency) and a drop guard. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Why
format_mode_redactbranch was 627 commits behind upstream, missing bugfixes across tracing 0.1.40→0.1.44, tracing-core 0.1.32→0.1.36, and tracing-attributes 0.1.27→0.1.31How
tracing-attributes/src/attr.rsandtracing-attributes/src/expand.rsNext steps
[patch.crates-io]sections to point to this branchformat_mode_redactbranch can then be deleted🤖 Generated with Claude Code