167 Commits

Author SHA1 Message Date
Jonas Platte
3a1f571102
Fix CI (#3361)
* Implement PartialOrd for MatchPattern, MatchDebug in terms of Ord
* Fix missing link to supported regex syntax
* Update expected trybuild output
* Fix tracing_subscriber::Layer links
2025-08-15 14:40:42 +09:00
Hayden Stainsby
e63ef57f3d
chore: prepare tracing-attributes 0.1.30 (#3316)
# 0.1.30 (June 17, 2025)

### Fixed

- Fix `tracing::instrument` regression around shadowing ([#3311])

[#3311]: https://github.com/tokio-rs/tracing/pull/3311
2025-06-17 17:25:57 +02:00
Jonas Platte
6e59a13b1a
attributes: fix tracing::instrument regression around shadowing (#3311)
The change to allow the `dead_code` lint to work on the
`#[instrument]` attribute (#3108) introduced a shadowing
problem which caused compilation failure in certain cases,
as reported in #3306.

The body of the original function was not given its own scope
and `use` statements made there could leak out into the
code inserted by the `#[instrument]`.

This change fixes this problem by explicitly re-introducing the
parenthesis to give the original function body its own scope.

Closes #3306
2025-06-13 12:05:56 +02:00
Hayden Stainsby
643f392ebb
chore: prepare tracing-attributes 0.1.29 (#3304)
# 0.1.29 (June 6, 2025)

### Changed

- Bump MSRV to 1.65 ([#3033])

### Fixed

- Let `dead_code` lint work on `#[instrument]`ed functions ([#3108])
- Globally qualify attribute paths ([#3126])

[#3033]: https://github.com/tokio-rs/tracing/pull/3033
[#3108]: https://github.com/tokio-rs/tracing/pull/3108
[#3126]: https://github.com/tokio-rs/tracing/pull/3126
2025-06-06 12:30:22 +02:00
Hayden Stainsby
c01d4fd9de
fix docs and enable CI on main branch (#3295)
## Motivation

The new `main` branch is forked from the `v0.1.x` branch. It will be
made the default branch and going forward we will merge PRs to this
branch first (and then forward port to a new `v0.2.x` branch forked from
`master`).

It looks like Netlify jobs weren't running on the `v0.1.x` branch, and so
there were quite a few errors in the docs on that branch (which isn't great
because those are the ones that get published to docs.rs).

## Solution

Separate to this PR, we've enabled Netlify on the `main` branch, and this
change fixes all the errors that were present in the docs.

This change sets the GitHub actions to run on the `main` branch instead
of `v0.1.x`. It also adds some text in the root README.md which
describes the branch set-up.

Refs: #3294
2025-06-05 10:15:18 +02:00
Rebecca Turner
09b70e265c Let dead_code lint work on #[instrument]ed functions (#3108)
Closes #1366
2025-06-03 09:47:35 +02:00
Heath Stewart
4deba4aaea attributes: Globally qualify attribute paths (#3126)
Avoid ambiguities with any user-defined `tracing` modules by globally qualifying types used in the attribute-generated code e.g., `::tracing::Level`.
2025-06-03 09:47:35 +02:00
Oscar Gustafsson
b3aa9de4c5 subscriber: update matchers to 0.2 (#3033)
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.
2025-06-03 09:47:35 +02:00
Rustin
3c07b083a6 chore: remove outdated release instructions (#3154)
The outdated release instructions have been removed.

Follow up of #2384.

Signed-off-by: Rustin170506 <tech@rustin.me>
2025-06-03 09:47:35 +02:00
Hayden Stainsby
f006df25b4 chore: fix Rust 1.86.0 lints (#3253)
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
2025-06-03 09:47:35 +02:00
Hayden Stainsby
6240c95518 chore: fix Rust 1.84.0 lints and errors (#3202)
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).
2025-01-24 18:58:17 +01:00
Hayden Stainsby
35f360a192
chore: fix new Clippy lints in Rust 1.83.0 (#3165)
Most of these changes are places where lifetimes were named, but can be
elided. Then a few cases where a lifetime was elided, but actually
resolves to a named lifetime. So lots of lifetimes.

This is the `v0.1.x` branch sister PR to #3164 (for the `master`
branch), since `clippy --fix` on another branch is a much better way to
apply these changes than backporting.
2024-11-29 16:51:58 +01:00
Hayden Stainsby
baa5489406
chore: prepare tracing-attributes 0.1.28 (#3155)
# 0.1.28 (November 26, 2024)

### Changed

- Bump MSRV to 1.63 ([#2793])

### Fixed

- Added missing RecordTypes for instrument ([#2781])
- Change order of async and unsafe modifier ([#2864])
- Extract match scrutinee ([#2880])
- Allow field path segments to be keywords ([#2925])
- Support const values for `target` and `name` ([#2941])

### Documented

- Fix backporting error in attributes ([#2780])

[#2780]: https://github.com/tokio-rs/tracing/pull/2780
[#2781]: https://github.com/tokio-rs/tracing/pull/2781
[#2793]: https://github.com/tokio-rs/tracing/pull/2793
[#2864]: https://github.com/tokio-rs/tracing/pull/2864
[#2880]: https://github.com/tokio-rs/tracing/pull/2880
[#2925]: https://github.com/tokio-rs/tracing/pull/2925
[#2941]: https://github.com/tokio-rs/tracing/pull/2941
2024-11-26 07:19:53 +01:00
Jonas Platte
40ae82f539 macros: allow field path segments to be keywords (#2925)
Currently, a keyword like `type` fails compilation as (a path segment of) a field name, for no clear reason. Trying to use `r#type` instead leads to the `r#` being part of the field name, which is unhelpful¹.

Don't require the field path to match a `macro_rules!` `expr`, use repeated `tt` instead. I can't tell why this was ever required: The internal stringify macro was introduced in 55091c92ed (diff-315c02cd05738da173861537577d159833f70f79cfda8cd7cf1a0d7a28ace31b) with an `expr` matcher without any explanation, and no tests are failing from making it match upstream's `stringify!` input format.

Special thanks to whoever implemented the unstable `macro-backtrace` feature in rustc, otherwise this would have been nigh impossible to track down!

¹ this can likely be fixed too by some sort of "unraw" macro that turns `r#foo` into `foo`, but that's a separate change not made in this PR
2024-11-22 15:42:14 +01:00
Dawid Ciężarkiewicz
5cebb65684 tracing-attributes: support const values for target and name (#2941)
Fixes #2960

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
Co-authored-by: Hayden Stainsby <hds@caffeineconcepts.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2024-11-22 15:42:14 +01:00
Hayden Stainsby
10e722e808 mock: add ExpectedId to link span expectations (#3007)
It currently isn't possible to differentiate spans with the same name,
target, and level when setting expectations on `enter`, `exit`, and
`drop_span`. This is not an issue for `tracing-mock`'s original (and
still primary) use case, which is to test `tracing` itself. However,
when testing the tracing instrumentation in library or application code,
this can be a limitation.

For example, when testing the instrumentation in tokio
(tokio-rs/tokio#6112), it isn't possible to set an expectation on which
task span is entered first, because the name, target, and level of those
spans are always identical - in fact, the spans have the same metadata
and only the field values are different.

To make differentiating different spans possible, `ExpectId` has been
introduced. It is an opaque struct which represents a `span::Id` and can
be used to match spans from a `new_span` expectation (where a `NewSpan`
is accepted and all fields and values can be expected) through to
subsequent `enter`, `exit`, and `drop_span` expectations.

An `ExpectedId` is passed to an `ExpectedSpan` which then needs to be
expected with `MockCollector::new_span`. A clone of the `ExpectedId` (or
a clone of the `ExpectedSpan` with the `ExpectedId` already on it) will
then match the ID assigned to the span to the other span lifecycle
expectations.

The `ExpectedId` uses an `Arc<AtomicU64>` which has the ID for the new
span assigned to it, and then its clones will be matched against that
same ID.

In future changes it will also be possible to use this `ExpectedId` to
match parent spans, currently a parent is only matched by name.
2024-11-20 15:57:49 +01:00
Hayden Stainsby
c6983d5167 mock: document public APIs in span module (#2442)
This change adds documentation to the tracing-mock span module and all
the public APIs within it. This includes doctests on all the methods
which serve as examples.

Additionally, the validation on `ExpectedSpan` was improved so that it
validates the level and target during `enter` and `exit` as well as on
`new_span`.

The method `ExpectedSpan::with_field` was renamed to `with_fields`
(plural) to match the same method on `ExpectedEvent` (and because
multiple fields can be passed to it).

A copy-paste typo was also fixed in the documentation for
`ExpectedEvent::with_contextual_parent`.

Refs: #539

Co-authored-by: David Barsky <me@davidbarsky.com>
2024-11-20 15:57:49 +01:00
Hayden Stainsby
ef4362b44f test: add tracing-test crate for non-publishable test utils (#2466)
There has been interest around publishing tracing-mock to crates.io
for some time. In order to make this possible, it needs to be cleaned up.

There are some test utils in the `tracing-mock` crate which wouldn't
make sense to publish. They provide test futures that are needed in
multiple `tracing-*` crates, but would likely not be needed outside that
context.

This change moves that functionality into a separate `tracing-test`
crate, which should never be published to crates.io.

Refs: #539

Co-authored-by: David Barsky <me@davidbarsky.com>
2024-11-20 15:57:49 +01:00
Dirkjan Ochtman
70a867877d
v0.1.x: clean up warnings (#3069)
* chore: avoid warnings from unknown cfg flags

* core: address warning for static-mut-refs

* chore: clean up warnings
2024-09-24 16:27:33 -04:00
Gabriel Goller
36bf06310c
attributes: extract match scrutinee (#2880)
On clippy version 1.76.0 this gives a warning, extracting the
scrutinee to a variable fixes this.

Fixes: #2876
2024-03-11 21:29:33 -04:00
Hayden Stainsby
571c5305bc
chore: fixes for clippy changes in Rust 1.74 (#2814)
With the release of Rust 1.74, there are some new or modified clippy
lints that need adaption in the code.

The main change was the removal of the `private_in_public`.
https://rust-lang.github.io/rfcs/2145-type-privacy.html

Then two more changes were required, in one case to adhere a lint and
the other to allow it. When talking about what an "application" needs to
do when setting up `tracing-error`, it makes sense to include `fn
main()` in the doctest, even though the lint recommends against it.
; Conflicts:
;	examples/examples/map-traced-error.rs
2024-03-01 12:53:37 -08:00
Gabriel Goller
0e4a4bef5e
attributes: change order of async and unsafe modifier (#2864)
When using `#[tracing::instrument]` and the `async unsafe` modifiers
the generated function read `unsafe async fn`, which is wrong. Corrected
the order and added a test.

Fixes: #2576

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-01-26 14:14:00 -08:00
David Barsky
c6abc10c3a chore: bump MSRV to 1.63 (#2793) 2023-11-07 13:37:19 -08:00
Gabriel Goller
4529182e60 attributes: added missing RecordTypes for instrument (#2781)
When using a function annotated with `#[instrument]` it parses the
parameters of the function and records them either using `Value` or
using `std::fmt::Debug`. There were a few types that implement `Value`
but were missing the RecordTypes array. Added them + a unit test for a
single one.

Fixed: #2775
2023-11-07 13:37:19 -08:00
Gabriel Goller
f622a1e83e
docs: fix backporting error in attributes (#2780)
There was an error when backporting #1378 (here: #1418) and a trailing
dot (.) was forgotten (which was breaking the link). Fixed also the link to
`std::fmt::Debug`.
2023-10-30 09:55:12 -04:00
David Barsky
2502f19d93
chore: prepare tracing-attributes 0.1.27 (#2756)
# 0.1.27 (October 13, 2023)

### Changed

- Bump minimum version of proc-macro2 to 1.0.60 (#2732)
- Generate less dead code for async block return type hint (#2709)

### Fixed

- Fix a compilation error in `#[instrument]` when the `"log"`
  feature is enabled (#2599)
2023-10-13 10:57:26 -07:00
Toby Murray
f96846d78a
attributes: fix typo "overriden" => "overridden" (#2719)
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
; Conflicts:
;	tracing-attributes/src/lib.rs
2023-10-12 12:08:20 -07:00
Eliza Weisman
f8c000202a
attributes: fix clippy warning in attributes tests (#2742)
Clippy doesn't like the redefinition of a binding with itself. I don't
think this was necessary for the bug we were reproducing here (as the
error test doesn't do this), so I removed it.
2023-10-12 12:07:38 -07:00
David Barsky
29f74c52c2 attributes: bump minimum version of proc-macro2 to 1.0.60 (#2732)
As part of landing #2728, I noticed that the `-Zminimal-versions` check fails
due to proc-macro2 1.0.40 referencing a since-removed, nightly-only
feature (`proc_macro_span_shrink`). Since this change doesn't change the MSRV
of `proc-macro2` (or `tracing`, for that matter), this feels like a safe change
to make.
2023-10-01 10:46:02 -07:00
Kornel
df6793f7b7 attributes: generate less dead code for async block return type hint (#2709)
## Motivation

`#[tracing::instrument]` uses `unreachable!()` macro which needlessly
expands to panicking and formatting code. It only needs any `!` type.

## Solution

`loop {}` works just as well for a `!` type, and it crates less work for
the compiler. The code is truly unreachable, so the message would never
be useful. Rust used to be concerned about semantics of empty loops in
LLVM, but this [has been solved](https://reviews.llvm.org/D85393).
2023-10-01 10:46:02 -07:00
Michael Wigard
70107bfad7 attributes: fix instrument with "log" feature (#2599)
## Motivation

The instrument macro currently doesn't work with the "log" crate
feature: #2585

## Solution

Change the generated code to create a span if either
`tracing::if_log_enabled!` or `tracing::level_enabled!`. I'm not sure
how to add a test for this or if this is the best solution.

Fixes #2585
2023-10-01 10:46:02 -07:00
Hayden Stainsby
5197803f23 mock: change helper functions to expect::<thing> (#2377)
* mock: change helper functions to `expect::<thing>`

The current format of test expectations in `tracing-mock` isn't ideal.
The format `span::expect` requires importing `tracing_mock::<thing>` which
may conflict with imports from other tracing crates, especially
`tracing-core`.

So we change the order and move the functions into a module called
`expect` so that:
* `event::expect` becomes `expect::event`
* `span::expect` becomes `expect::span`
* `field::expect` becomes `expect::field`

This format has two advantages.
1. It reads as natural English, e.g "expect span"
2. It is no longer common to import the modules directly.

Regarding point (2), the following format was previously common:

```rust
use tracing_mock::field;

field::expect();
```

This import of the `field` module may then conflict with importing the
same from `tracing_core`, making it necessary to rename one of the
imports.

The same code would now be written:

```rust
use tracing_mock::expect;

expect::field();
```

Which is less likely to conflict.

This change also fixes an unused warning on `MockHandle::new` when the
`tracing-subscriber` feature is not enabled.

Refs: #539
2023-10-01 10:46:02 -07:00
Hayden Stainsby
48b8266f49 mock: differentiate between mocks and expectations (#2373)
The `tracing-mock` crate provides a mock collector (and a subscriber for
use by the tests in the `tracing-subscriber` crate) which is able to
make assertions about what diagnostics are emitted.

These assertions are defined by structs that match on events, span, and
their fields and metadata. The structs that matched these objects have
been called, up until now, mocks, however this terminology may be
misleading, as the created objects don't mock anything.

There were two different names for similar functionality with `only()`
and `done()` on fields and collectors/subscribers respectively. Using a
single name for these may make it easier to onboard onto `tracing-mock`.

To reduce confusion, these structs have been split into two categories:
mocks and expectations.

Additionally, the `done()` function on the `Collector` and `Subscriber`
mocks has been replaced with `only()`. This matches the similar function
for `ExpectedField`, and may be more intuitive.

The mocks replace some component in the tracing ecosystem when a library
is under test. The expectations define the assertions we wish to make
about traces received by the mocks.

Mocks (per module):
* collector - `MockCollector`, no change
* subscriber - `MockSubscriber`, renamed from `ExpectSubscriber`

Expectations (per module):
* event - `ExpectedEvent`, renamed from `MockEvent`
* span - `ExpectedSpan`, renamed from `MockSpan`
* field - `ExpectedField` and `ExpectedFields`, renamed from `MockField`
  and `Expected`. Also `ExpectedValue` renamed from `MockValue`.
* metadata - `ExpectedMetadata`, renamed from `Expected`

Refs: #539
2023-10-01 10:46:02 -07:00
Eliza Weisman
430206459b
attributes: prepare to release v0.1.26 (#2631)
# 0.1.26 (June 21th, 2023)

This release of `tracing-attributes` fixes warnings due to `allow`
attributes in generated code that allow lints which may not exist on
earlier versions of rustc.

### Fixed

- Allow `unknown_lints` in macro-generated code ([#2626])

Thanks to @mladedav for contributing to this release!
2023-06-21 17:50:58 -07:00
David Mládek
a347f319d3
attributes: allow unknown_lints in generated code (#2626)
## Motivation

#2609 added an allow to generated code to allow a lint that was added in
Clippy 1.70.0. This was released with a patch bump so anyone who uses an
older version and latest tracing gets a compilation warning about an
unkonwn lint.

## Solution

Allowing unkonwn lints should fix this now and prevent similar issues in
the future. If the lints are unknown it will most likely be because the
lints are introduced only in newer compiler. There is just a higher risk
that a future contributor tries to add another allow and if they make a
typo, the issue will not be caught.
2023-06-21 15:54:34 -07:00
Eliza Weisman
02a0badf37
attributes: prepare to release v0.1.25 (#2625)
# 0.1.25 (June 19th, 2023)

This release of `tracing-attributes` fixes the Clippy lint
[`let_with_type_underscore`] in code generated by the `#[instrument]`
attribute in Rust 1.70+.

### Fixed

- Allow [`clippy::let_with_type_underscore`] in macro-generated code
  ([#2609])

Thanks to @coolreader19 for contributing to this release!

[#2609]: https://github.com/tokio-rs/tracing/pull/2609

[`let_with_type_underscore`]: http://rust-lang.github.io/rust-clippy/rust-1.70.0/index.html#let_with_type_underscore
2023-06-19 06:45:55 -07:00
Noa
a6fcd7cc4c attributes: fix clippy::let_with_type_underscore in generated code (#2609)
Co-authored-by: Hayden Stainsby <hds@caffeineconcepts.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-06-19 06:26:02 -07:00
Eliza Weisman
e35265a0a1
attributes: prepare to release v0.1.24 (#2574)
# 0.1.24 (April 24th, 2023)

This release of `tracing-attributes` adds support for passing an
optional `level` to the `err` and `ret` arguments to `#[instrument]`,
allowing the level of the generated return-value event to be overridden.
For example,

```rust
#[instrument(err(level = "info"))]
fn my_great_function() -> Result<(), &'static str> {
    // ...
}
```

will emit an `INFO`-level event if the function returns an `Err`.

In addition, this release updates the [`syn`] dependency to v2.x.x.

### Added

- `level` argument to `err` and `ret` to override the level of the
  generated return value event (#2335)
- Improved compiler error message when `#[instrument]` is added to a
  `const fn` (#2418)

### Changed

- Updated `syn` dependency to 2.0 (#2516)

### Fixed

- Fix `clippy::unreachable` warnings in `#[instrument]`-generated code
  (#2356)
- Removed unused "visit" feature flag from `syn` dependency (#2530)

### Documented

- Documented default level for `err` (#2433)
- Improved documentation for levels in `#[instrument]` (#2350)

Thanks to @nitnelave, @jsgf, @Abhicodes-crypto, @LukeMathWalker,
@andrewpollack, @quad, @klensy, @davidpdrsn, and @dbidwell94 for
contributign to this release!

[`syn`]: https://crates.io/crates/syn
2023-04-24 09:36:46 -07:00
Devin Bidwell
b9becf90fe attributes: update UI tests with the latest stable version of Rust (#2568)
updated UI tests using TRYBUILD=overwrite with the latest stable version of Rust

## Motivation

UI tests are failing on the latest stable version of Rust

## Solution

Run `TRYBUILD=overwrite cargo test` to update the effected files.
2023-04-21 16:59:51 -07:00
Ilya Salauyeu
3a65354837 tracing, tracing-futures: instrument Future inside Drop (#2562)
## Motivation

Currently it is not possible to disable ANSI in `fmt::Subscriber`
without enabling the "ansi" crate feature. This makes it difficult for
users to implement interoperable settings that are controllable with
crate features without having to pull in the dependencies "ansi" does.

I hit this while writing an application with multiple logging options
set during compile-time and I wanted to cut down on dependencies if
possible.

## Solution

This changes `fmt::Subscriber::with_ansi()` to not require the "ansi"
feature flag. This way, `with_ansi(false)` can be called even when the
"ansi" feature is disabled. Calling `with_ansi(true)` when the "ansi"
feature is not enabled will panic in debug mode, or print a warning if
debug assertions are disabled.

Co-authored-by: daxpedda <daxpedda@gmail.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-04-21 16:59:51 -07:00
David Pedersen
a066c36729 attributes: update to syn 2.0 (#2516)
## Motivation

syn 2.0 is out!

## Solution

Update to syn 2.0 🚀

Co-authored-by: David Barsky <me@davidbarsky.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-04-21 16:59:51 -07:00
klensy
27eecd5fd7 attributes: remove unused syn's feature visit (#2530)
Remove unused `syn`s feature `visit`
; Conflicts:
;	tracing-attributes/Cargo.toml
2023-04-21 16:59:51 -07:00
David Barsky
45a2cea8bb subscriber: dim Compact targets, matching the default formatter (#2409)
Fixes https://github.com/tokio-rs/tracing/issues/2408

Just switch to use `dim`

Before:
![2022-12-08_13-58-40](https://user-images.githubusercontent.com/623453/206576169-63ee4e20-b56f-4c63-a9b3-80ba2e97eec9.png)
After:
![2022-12-08_13-55-36](https://user-images.githubusercontent.com/623453/206576055-878d360f-7b95-4e18-bc31-4fb6f1b71a3a.png)
Full mode for comparison:
![2022-12-08_13-55-48](https://user-images.githubusercontent.com/623453/206576054-6e38852c-cb3a-4b84-98e5-50463cdb5073.png)
; Conflicts:
;	tracing-subscriber/src/fmt/format/mod.rs
2023-04-21 16:59:51 -07:00
Scott Robinson
c2cde4f1fc attributes: document default level for err (#2433)
## Motivation

The current description for the default level of the `err` return value
event _strongly implies_ it's the same as the span. However, the
implementation actually defaults to `ERROR`.

## Solution

This PR documents that, so future generations don't have to chase down
the truth, like I did. 😉
2023-04-21 16:59:51 -07:00
Andrew Pollack
7cceb79b11 attributes: add compile error on const fn instrumentation (#2418)
## Motivation

The `#[instrument]` macro cannot be used on `const fn`s, because the
generated code will perform runtime tracing behavior. However, when
adding the attribute to a `const fn`, the compiler errors generated
currently are somewhat unclear (see #2414). It would be better if we
generated a less verbose error that simply states that `#[instrument]`
is not supported on `const fn`s.

## Solution

This branch changes the `#[instrument]` macro to detect when the
annotated function is a `const fn`, and emit a simpler, more descritpive
error message. The new error simply states that the `#[instrument]`
attribute cannot be used on `const fn`s, and should be much less
confusing to the user.

Fixes #2414
2023-04-21 16:59:51 -07:00
Luca Palmieri
6c55b66915 chore: Remove doc(html_root_url) attribute from all crates. (#2384)
Fixes #2383.
; Conflicts:
;	tracing-appender/src/lib.rs
;	tracing-attributes/src/lib.rs
;	tracing-core/src/lib.rs
;	tracing-error/src/lib.rs
;	tracing-futures/src/lib.rs
;	tracing-log/src/lib.rs
;	tracing-opentelemetry/src/lib.rs
;	tracing-serde/src/lib.rs
;	tracing-subscriber/src/lib.rs
;	tracing/src/lib.rs
2023-04-21 16:59:51 -07:00
Abhishek
6bd3d40d2b attributes: allow clippy::unreachable warning (#2356)
## Motivation

PR #2270 added an unreachable branch with an explicit return value to
`#[instrument]` in `async fn`s in order to fix type inference issues.
That PR added the appropriate `#[allow]` attribute for the Rust
compiler's unreachable code linting, but not Clippy's, so a Clippy
warning is still emitted. See:
https://github.com/tokio-rs/tracing/pull/2270#issuecomment-1282881008

## Solution

Adding the clippy lint warning as discussed here:
https://github.com/tokio-rs/tracing/pull/2270#issuecomment-1282887973
2023-04-21 16:59:51 -07:00
Jeremy Fitzhardinge
b38122deff attributes: improve docs; tests for using Levels in #[instrument] (#2350)
This branch adds documentation and tests noting that the `#[instrument]`
macro accepts `tracing::Level` directly. Using `tracing::Level` directly
allows for IDE autocomplete and earlier detection of typos.

The documentation for tracing-attributes was also rewritten to remove
the usage of the second-person perspective, making it more consistent
with the rest of tracing's documentation.

Co-authored-by: David Barsky <me@davidbarsky.com>
; Conflicts:
;	tracing-attributes/Cargo.toml
;	tracing-attributes/src/lib.rs
2023-04-21 16:59:51 -07:00
nitnelave
89d0ca845d attributes: support custom levels for ret and err (#2335)
This branch adds the ability to override the level of the events
generated by the `ret` and `err` arguments to `#[instrument]`. An
overridden level can be specified with:

```rust

```
```rust

```
and so on.

This syntax is fully backwards compatible with existing uses of the
attribute.

In addition, some refactoring was done to how levels are parsed and how
the tokens for a specified level is generated.

Fixes #2330
; Conflicts:
;	tracing-attributes/src/lib.rs
2023-04-21 16:59:51 -07:00
keepsimple1
d2f47f1e3f
chore: fix clippy warnings for v0.1.x (#2552)
## Motivation

Clippy check fails in recent CI runs in v0.1.x branch PRs, for example
this run:
https://github.com/tokio-rs/tracing/actions/runs/4641107803/jobs/8215263838


Relevant error logs:
```
error: lint `const_err` has been removed: converted into hard error, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> for more information
   --> tracing-core/src/lib.rs:132:5
    |
132 |     const_err,
    |     ^^^^^^^^^
    |
    = note: `-D renamed-and-removed-lints` implied by `-D warnings`


error: deref which would be done by auto-deref
   --> tracing-core/src/dispatcher.rs:371:26
    |
371 |                 return f(&*entered.current());
    |                          ^^^^^^^^^^^^^^^^^^^ help: try this: `&entered.current()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
    = note: `-D clippy::explicit-auto-deref` implied by `-D warnings`


error: deref which would be done by auto-deref
   --> tracing-core/src/dispatcher.rs:393:20
    |
393 |             Some(f(&*entered.current()))
    |                    ^^^^^^^^^^^^^^^^^^^ help: try this: `&entered.current()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
```

## Solution

Fix the warnings based on the suggestions for Clippy.
2023-04-12 21:22:44 +00:00