Skip to content
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

chore: backport roughly a year's worth of changes #2728

Merged
merged 34 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5048b86
mock: differentiate between mocks and expectations (#2373)
hds Nov 10, 2022
dc636df
mock: change helper functions to `expect::<thing>` (#2377)
hds Nov 11, 2022
9c6ffce
mock: add README to tracing-mock (#2362)
hds Nov 15, 2022
5db72b6
attributes: update `async_instrument` error text for Rust 1.66 (#2427)
hds Dec 27, 2022
e8b3795
mock: document public APIs in `event` module (#2426)
hds Jan 5, 2023
cbcfbf9
mock: document public APIs in `subscriber` module (#2446)
hds Jan 26, 2023
516392c
docs: fix typo in `panic_hook` example (#2453)
arifd Feb 8, 2023
d55ce3d
chore: bump MSRV to 1.56 (#2546)
davidbarsky Apr 5, 2023
bcaeaa9
core: add `ValueSet::len` and `Record::len` (#2152)
jamesmunns Jun 7, 2022
bb81c7e
mock: document public API in collector module (#2389)
hds Jun 24, 2023
0b31599
tracing: use fully qualified names in macros for items exported from …
hlbarber Jul 11, 2023
ddb1b8a
chores: fix clippy lints (#2673)
davidbarsky Aug 3, 2023
8e77a43
tracing: add tracing-cloudwatch to related cates in README (#2667)
ymgyt Aug 7, 2023
5952e36
documentation: Add article and talk by hoverbear (#2679)
Hoverbear Aug 9, 2023
8cb22ff
core: ensure callsites in test have unique addresses (#2681)
nikic Aug 14, 2023
2ee84b3
docs(field): remove duplicate wording (#2674)
alextes Aug 14, 2023
1fa24df
docs: Add `clippy-tracing` to related crates (#2628)
JonathanWoollett-Light Aug 14, 2023
5da7799
tracing: fix `wasm_bindgen_test` macros (#2675)
hlbarber Aug 17, 2023
bbc87fe
subscriber: support `NO_COLOR` in `fmt::Layer` (#2647)
dmlary Aug 17, 2023
95b1d5c
chore: fix new warnings in Rust 1.72.0 (#2700)
hawkw Aug 29, 2023
316c5a1
attributes: fix instrument with "log" feature (#2599)
miwig Sep 5, 2023
7d63c84
appender: clarify file appender docs (#2689)
CLEckhardt Sep 5, 2023
e4bb093
flame: fix folded formatting (#2710)
conectado Sep 5, 2023
b658b1f
attributes: generate less dead code for async block return type hint …
kornelski Sep 5, 2023
b0e3c71
core: allow `ValueSet`s of any length (#2508)
eopb Sep 5, 2023
3b1851d
tracing: allow setting event names in macros (#2699)
twitchax Sep 5, 2023
a0a176e
journald: allow custom journal fields (#2708)
Finomnis Sep 5, 2023
0687403
tracing: allow constant field names in macros (#2617)
wyfo Sep 5, 2023
75f0dbf
docs: add `axum-insights` to relevant crates. (#2713)
twitchax Sep 6, 2023
66d96cd
[tracing-subscriber]: add chrono crate implementations of FormatTime …
shayne-fletcher Sep 25, 2023
ffb1b11
test: remove potentially problematic test (#2728)
davidbarsky Sep 27, 2023
b661e84
attributes: bump minimum version of proc-macro2 to 1.0.60 (#2732)
davidbarsky Sep 28, 2023
f875c16
subscriber: Implement layer::Filter for Option<Filter> (#2407)
jsgf Sep 28, 2023
aa51104
docs: remove usage of 0.2 terminology (#2728)
davidbarsky Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: fix new warnings in Rust 1.72.0 (#2700)
This branch fixes a handful of new warnings which have shown up after
updating to Rust 1.72.0.

This includes:

* `clippy::redundant_closure_call` in macros --- allowed because the
  macro sometimes calls a function that isn't a closure, and the closure
  is just used in the case where it's not a function.
* Unnecessary uses of `#` in raw string literals that don't contain `"`
  characters.
* Dead code warnings with specific feature flag combinations in
  `tracing-subscriber`.

In addition, I've fixed a broken RustDoc link that was making the
Netlify build sad.
  • Loading branch information
hawkw authored and davidbarsky committed Sep 29, 2023
commit 95b1d5ce74f0bd3305a8e25ad79edee2326fda6b
1 change: 1 addition & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[build.environment]
RUSTDOCFLAGS="""
-D warnings \
--force-warn rustdoc::redundant-explicit-links \
--force-warn renamed-and-removed-lints \
--cfg docsrs \
--cfg tracing_unstable
Expand Down
8 changes: 8 additions & 0 deletions tracing-core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ macro_rules! impl_one_value {
impl $crate::sealed::Sealed for $value_ty {}
impl $crate::field::Value for $value_ty {
fn record(&self, key: &$crate::field::Field, visitor: &mut dyn $crate::field::Visit) {
// `op` is always a function; the closure is used because
// sometimes there isn't a real function corresponding to that
// operation. the clippy warning is not that useful here.
#[allow(clippy::redundant_closure_call)]
visitor.$record(key, $op(*self))
}
}
Expand All @@ -485,6 +489,10 @@ macro_rules! impl_one_value {
impl $crate::sealed::Sealed for ty_to_nonzero!($value_ty) {}
impl $crate::field::Value for ty_to_nonzero!($value_ty) {
fn record(&self, key: &$crate::field::Field, visitor: &mut dyn $crate::field::Visit) {
// `op` is always a function; the closure is used because
// sometimes there isn't a real function corresponding to that
// operation. the clippy warning is not that useful here.
#[allow(clippy::redundant_closure_call)]
visitor.$record(key, $op(self.get()))
}
}
Expand Down
3 changes: 1 addition & 2 deletions tracing-subscriber/src/field/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub trait VisitOutput<Out>: Visit {
/// Extension trait implemented by types which can be recorded by a [visitor].
///
/// This allows writing code that is generic over `tracing_core`'s
/// [`span::Attributes`][attr], [`span::Record`][rec], and [`Event`][event]
/// [`span::Attributes`][attr], [`span::Record`][rec], and [`Event`]
/// types. These types all provide inherent `record` methods that allow a
/// visitor to record their fields, but there is no common trait representing this.
///
Expand Down Expand Up @@ -85,7 +85,6 @@ pub trait VisitOutput<Out>: Visit {
/// [visitor]: tracing_core::field::Visit
/// [attr]: tracing_core::span::Attributes
/// [rec]: tracing_core::span::Record
/// [event]: tracing_core::event::Event
pub trait RecordFields: crate::sealed::Sealed<RecordFieldsMarker> {
/// Record all the fields in `self` with the provided `visitor`.
fn record(&self, visitor: &mut dyn Visit);
Expand Down
5 changes: 3 additions & 2 deletions tracing-subscriber/src/filter/directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ enum ParseErrorKind {
// === impl DirectiveSet ===

impl<T> DirectiveSet<T> {
#[cfg(feature = "env-filter")]
// this is only used by `env-filter`.
#[cfg(all(feature = "std", feature = "env-filter"))]
pub(crate) fn is_empty(&self) -> bool {
self.directives.is_empty()
}
Expand Down Expand Up @@ -397,7 +398,7 @@ impl FromStr for StaticDirective {
// === impl ParseError ===

impl ParseError {
#[cfg(feature = "env-filter")]
#[cfg(all(feature = "std", feature = "env-filter"))]
pub(crate) fn new() -> Self {
ParseError {
kind: ParseErrorKind::Other(None),
Expand Down
23 changes: 15 additions & 8 deletions tracing-subscriber/src/filter/env/directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ impl Directive {
}

pub(super) fn parse(from: &str, regex: bool) -> Result<Self, ParseError> {
static DIRECTIVE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(
r"(?x)
static DIRECTIVE_RE: Lazy<Regex> = Lazy::new(|| {
Regex::new(
r"(?x)
hawkw marked this conversation as resolved.
Show resolved Hide resolved
^(?P<global_level>(?i:trace|debug|info|warn|error|off|[0-5]))$ |
# ^^^.
# `note: we match log level names case-insensitively
Expand All @@ -135,15 +136,18 @@ impl Directive {
# `note: we match log level names case-insensitively
)?
$
"
)
.unwrap());
",
)
.unwrap()
});
static SPAN_PART_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r#"(?P<name>[^\]\{]+)?(?:\{(?P<fields>[^\}]*)\})?"#).unwrap());
Lazy::new(|| Regex::new(r"(?P<name>[^\]\{]+)?(?:\{(?P<fields>[^\}]*)\})?").unwrap());
static FIELD_FILTER_RE: Lazy<Regex> =
// TODO(eliza): this doesn't _currently_ handle value matchers that include comma
// characters. We should fix that.
Lazy::new(|| Regex::new(r#"(?x)
Lazy::new(|| {
Regex::new(
r"(?x)
(
# field name
[[:word:]][[[:word:]]\.]*
Expand All @@ -152,7 +156,10 @@ impl Directive {
)
# trailing comma or EOS
(?:,\s?|$)
"#).unwrap());
",
)
.unwrap()
});

let caps = DIRECTIVE_RE.captures(from).ok_or_else(ParseError::new)?;

Expand Down
13 changes: 10 additions & 3 deletions tracing-subscriber/src/fmt/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ pub struct FieldFnVisitor<'a, F> {
/// Marker for [`Format`] that indicates that the compact log format should be used.
///
/// The compact format includes fields from all currently entered spans, after
/// the event's fields. Span names are listed in order before fields are
/// displayed.
/// the event's fields. Span fields are ordered (but not grouped) by
/// span, and span names are not shown. A more compact representation of the
/// event's [`Level`] is used, and additional information—such as the event's
/// target—is disabled by default.
///
/// # Example Output
///
Expand Down Expand Up @@ -1086,7 +1088,12 @@ where

let mut needs_space = false;
if self.display_target {
write!(writer, "{}{}", dimmed.paint(meta.target()), dimmed.paint(":"))?;
write!(
writer,
"{}{}",
dimmed.paint(meta.target()),
dimmed.paint(":")
)?;
needs_space = true;
}

Expand Down
11 changes: 7 additions & 4 deletions tracing-subscriber/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ where

/// Sets the subscriber being built to use a JSON formatter.
///
/// See [`format::Json`][super::fmt::format::Json]
/// See [`format::Json`] for details.
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn json(
Expand All @@ -783,7 +783,7 @@ where
impl<T, F, W> SubscriberBuilder<format::JsonFields, format::Format<format::Json, T>, F, W> {
/// Sets the json subscriber being built to flatten event metadata.
///
/// See [`format::Json`][super::fmt::format::Json]
/// See [`format::Json`] for details.
pub fn flatten_event(
self,
flatten_event: bool,
Expand All @@ -797,7 +797,7 @@ impl<T, F, W> SubscriberBuilder<format::JsonFields, format::Format<format::Json,
/// Sets whether or not the JSON subscriber being built will include the current span
/// in formatted events.
///
/// See [`format::Json`][super::fmt::format::Json]
/// See [`format::Json`] for details.
pub fn with_current_span(
self,
display_current_span: bool,
Expand All @@ -811,7 +811,7 @@ impl<T, F, W> SubscriberBuilder<format::JsonFields, format::Format<format::Json,
/// Sets whether or not the JSON subscriber being built will include a list (from
/// root to leaf) of all currently entered spans in formatted events.
///
/// See [`format::Json`][super::fmt::format::Json]
/// See [`format::Json`] for details.
pub fn with_span_list(
self,
display_span_list: bool,
Expand Down Expand Up @@ -1304,6 +1304,9 @@ mod test {
Self { buf }
}

// this is currently only used by the JSON formatter tests. if we need
// it elsewhere in the future, feel free to remove the `#[cfg]`
// attribute!
#[cfg(feature = "json")]
pub(crate) fn buf(&self) -> MutexGuard<'_, Vec<u8>> {
self.buf.lock().unwrap()
Expand Down
9 changes: 4 additions & 5 deletions tracing-subscriber/src/fmt/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tracing_core::Metadata;
/// This trait is already implemented for function pointers and
/// immutably-borrowing closures that return an instance of [`io::Write`], such
/// as [`io::stdout`] and [`io::stderr`]. Additionally, it is implemented for
/// [`std::sync::Mutex`][mutex] when the type inside the mutex implements
/// [`std::sync::Mutex`] when the type inside the mutex implements
/// [`io::Write`].
///
/// # Examples
Expand Down Expand Up @@ -66,7 +66,7 @@ use tracing_core::Metadata;
/// ```
///
/// A single instance of a type implementing [`io::Write`] may be used as a
/// `MakeWriter` by wrapping it in a [`Mutex`][mutex]. For example, we could
/// `MakeWriter` by wrapping it in a [`Mutex`]. For example, we could
/// write to a file like so:
///
/// ```
Expand All @@ -88,7 +88,6 @@ use tracing_core::Metadata;
/// [`Event`]: tracing_core::event::Event
/// [`io::stdout`]: std::io::stdout()
/// [`io::stderr`]: std::io::stderr()
/// [mutex]: std::sync::Mutex
/// [`MakeWriter::make_writer_for`]: MakeWriter::make_writer_for
/// [`Metadata`]: tracing_core::Metadata
/// [levels]: tracing_core::Level
Expand Down Expand Up @@ -325,7 +324,7 @@ pub trait MakeWriterExt<'a>: MakeWriter<'a> {

/// Wraps `self` with a predicate that takes a span or event's [`Metadata`]
/// and returns a `bool`. The returned [`MakeWriter`]'s
/// [`MakeWriter::make_writer_for`][mwf] method will check the predicate to
/// [`MakeWriter::make_writer_for`] method will check the predicate to
/// determine if a writer should be produced for a given span or event.
///
/// If the predicate returns `false`, the wrapped [`MakeWriter`]'s
Expand Down Expand Up @@ -544,7 +543,7 @@ pub struct BoxMakeWriter {
name: &'static str,
}

/// A [writer] that is one of two types implementing [`io::Write`][writer].
/// A [writer] that is one of two types implementing [`io::Write`].
///
/// This may be used by [`MakeWriter`] implementations that may conditionally
/// return one of two writers.
Expand Down
6 changes: 2 additions & 4 deletions tracing-subscriber/src/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,9 @@ pub trait SpanData<'a> {

/// A reference to [span data] and the associated [registry].
///
/// This type implements all the same methods as [`SpanData`][span data], and
/// provides additional methods for querying the registry based on values from
/// the span.
/// This type implements all the same methods as [`SpanData`], and provides
/// additional methods for querying the registry based on values from the span.
///
/// [span data]: SpanData
/// [registry]: LookupSpan
#[derive(Debug)]
pub struct SpanRef<'a, R: LookupSpan<'a>> {
Expand Down