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

Make NoSubscriber public and move it to tracing_core::subscriber #1549

Merged
merged 3 commits into from
Sep 11, 2021

Conversation

jsgf
Copy link
Contributor

@jsgf jsgf commented Sep 10, 2021

This is useful when you need a placeholder subscriber for something.

@jsgf jsgf requested review from hawkw and a team as code owners September 10, 2021 21:18
Just in case it ever needs a real field later.
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, thanks!

@hawkw hawkw merged commit 4f5ef51 into tokio-rs:v0.1.x Sep 11, 2021
hawkw added a commit that referenced this pull request Sep 12, 2021
# 0.1.20 (September 12, 2021)

This release adds support for `f64` as one of the `tracing-core`
primitive field values, allowing floating-point values to be recorded as
typed values rather than with `fmt::Debug`. Additionally, it adds
`NoSubscriber`, a `Subscriber` implementation that does nothing.
### Added

- **subscriber**: `NoSubscriber`, a no-op `Subscriber` implementation
  ([#1549])
- **field**: Added `Visit::record_f64` and support for recording
  floating-point values ([#1507])

Thanks to new contributors @jsgf and @maxburke for contributing to this
release!

[#1549]: #1549
[#1507]: #1507
hawkw added a commit that referenced this pull request Sep 12, 2021
# 0.1.20 (September 12, 2021)

This release adds support for `f64` as one of the `tracing-core`
primitive field values, allowing floating-point values to be recorded as
typed values rather than with `fmt::Debug`. Additionally, it adds
`NoSubscriber`, a `Subscriber` implementation that does nothing.
### Added

- **subscriber**: `NoSubscriber`, a no-op `Subscriber` implementation
  ([#1549])
- **field**: Added `Visit::record_f64` and support for recording
  floating-point values ([#1507])

Thanks to new contributors @jsgf and @maxburke for contributing to this
release!

[#1549]: #1549
[#1507]: #1507
hawkw added a commit that referenced this pull request Sep 13, 2021
# 0.1.27 (September 13, 2021)

This release adds a new [`Span::or_current`] method to aid in
efficiently propagating span contexts to spawned threads or tasks.
Additionally, it updates the [`tracing-core`] version to [0.1.20] and
the [`tracing-attributes`] version to [0.1.16], ensuring that a number
of new features in those crates are present.

### Fixed

- **instrument**: Added missing `WithSubscriber` implementations for
  futures and other types ([#1424])

### Added

- `Span::or_current` method, to help with efficient span context
  propagation ([#1538])
- **attributes**: add `skip_all` option to `#[instrument]` ([#1548])
- **attributes**: record primitive types as primitive values rather than
  as `fmt::Debug` ([#1378])
- **core**: `NoSubscriber`, a no-op `Subscriber` implementation
  ([#1549])
- **core**: Added `Visit::record_f64` and support for recording
  floating-point values ([#1507], [#1522])
- A large number of documentation improvements and fixes ([#1369],
  [#1398], [#1435], [#1442], [#1524], [#1556])

Thanks to new contributors @dzvon and @mbergkvist, as well as @teozkr,
@maxburke, @LukeMathWalker, and @jsgf, for contributing to this release!

[`Span::or_current`]: https://docs.rs/tracing/0.1.27/tracing/struct.Span.html#method.or_current
[`tracing-core`]: https://crates.io/crates/tracing-core
[`tracing-attributes`]: https://crates.io/crates/tracing-attributes
[`tracing-core`]: https://crates.io/crates/tracing-core
[0.1.20]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.20
[0.1.16]: https://github.com/tokio-rs/tracing/releases/tag/tracing-attributes-0.1.16
[#1424]: #1424
[#1538]: #1538
[#1548]: #1548
[#1378]: #1378
[#1507]: #1507
[#1522]: #1522
[#1369]: #1369
[#1398]: #1398
[#1435]: #1435
[#1442]: #1442
hawkw added a commit that referenced this pull request Sep 13, 2021
# 0.1.27 (September 13, 2021)

This release adds a new [`Span::or_current`] method to aid in
efficiently propagating span contexts to spawned threads or tasks.
Additionally, it updates the [`tracing-core`] version to [0.1.20] and
the [`tracing-attributes`] version to [0.1.16], ensuring that a number
of new features in those crates are present.

### Fixed

- **instrument**: Added missing `WithSubscriber` implementations for
  futures and other types (#1424)

### Added

- `Span::or_current` method, to help with efficient span context
  propagation (#1538)
- **attributes**: add `skip_all` option to `#[instrument]` (#1548)
- **attributes**: record primitive types as primitive values rather than
  as `fmt::Debug` (#1378)
- **core**: `NoSubscriber`, a no-op `Subscriber` implementation
  (#1549)
- **core**: Added `Visit::record_f64` and support for recording
  floating-point values (#1507, #1522)
- A large number of documentation improvements and fixes (#1369,
  #1398, #1435, #1442, #1524, #1556)

Thanks to new contributors @dzvon and @mbergkvist, as well as @teozkr,
@maxburke, @LukeMathWalker, and @jsgf, for contributing to this release!

[`Span::or_current`]: https://docs.rs/tracing/0.1.27/tracing/struct.Span.html#method.or_current
[`tracing-core`]: https://crates.io/crates/tracing-core
[`tracing-attributes`]: https://crates.io/crates/tracing-attributes
[`tracing-core`]: https://crates.io/crates/tracing-core
[0.1.20]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.20
[0.1.16]: https://github.com/tokio-rs/tracing/releases/tag/tracing-attributes-0.1.16
facebook-github-bot pushed a commit to facebook/fb303 that referenced this pull request Sep 15, 2021
Summary:
This includes recent changes:
- `skip_all` in #[instrument] tokio-rs/tracing#1548
- NoSubscriber no-op Subscriber tokio-rs/tracing#1549
- Box/Arc Layer (tokio-rs/tracing#1536 +
  tokio-rs/tracing#1547)
- log filtering fixes tokio-rs/tracing#1543

Local: force `log` and `log-always` features off. This removes the
`enable-trace-logging` flag from smartplatform/reconciler.

Reviewed By: guswynn

Differential Revision: D30906032

fbshipit-source-id: fdc3e4e29a39e9e181d9f4ff017e6b3e16acdcd8
facebook-github-bot pushed a commit to facebook/fbthrift that referenced this pull request Sep 15, 2021
Summary:
This includes recent changes:
- `skip_all` in #[instrument] tokio-rs/tracing#1548
- NoSubscriber no-op Subscriber tokio-rs/tracing#1549
- Box/Arc Layer (tokio-rs/tracing#1536 +
  tokio-rs/tracing#1547)
- log filtering fixes tokio-rs/tracing#1543

Local: force `log` and `log-always` features off. This removes the
`enable-trace-logging` flag from smartplatform/reconciler.

Reviewed By: guswynn

Differential Revision: D30906032

fbshipit-source-id: fdc3e4e29a39e9e181d9f4ff017e6b3e16acdcd8
facebook-github-bot pushed a commit to facebookexperimental/rust-shed that referenced this pull request Sep 15, 2021
Summary:
This includes recent changes:
- `skip_all` in #[instrument] tokio-rs/tracing#1548
- NoSubscriber no-op Subscriber tokio-rs/tracing#1549
- Box/Arc Layer (tokio-rs/tracing#1536 +
  tokio-rs/tracing#1547)
- log filtering fixes tokio-rs/tracing#1543

Local: force `log` and `log-always` features off. This removes the
`enable-trace-logging` flag from smartplatform/reconciler.

Reviewed By: guswynn

Differential Revision: D30906032

fbshipit-source-id: fdc3e4e29a39e9e181d9f4ff017e6b3e16acdcd8
facebook-github-bot pushed a commit to facebookincubator/antlir that referenced this pull request Sep 15, 2021
Summary:
This includes recent changes:
- `skip_all` in #[instrument] tokio-rs/tracing#1548
- NoSubscriber no-op Subscriber tokio-rs/tracing#1549
- Box/Arc Layer (tokio-rs/tracing#1536 +
  tokio-rs/tracing#1547)
- log filtering fixes tokio-rs/tracing#1543

Local: force `log` and `log-always` features off. This removes the
`enable-trace-logging` flag from smartplatform/reconciler.

Reviewed By: guswynn

Differential Revision: D30906032

fbshipit-source-id: fdc3e4e29a39e9e181d9f4ff017e6b3e16acdcd8
facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Sep 15, 2021
Summary:
This includes recent changes:
- `skip_all` in #[instrument] tokio-rs/tracing#1548
- NoSubscriber no-op Subscriber tokio-rs/tracing#1549
- Box/Arc Layer (tokio-rs/tracing#1536 +
  tokio-rs/tracing#1547)
- log filtering fixes tokio-rs/tracing#1543

Local: force `log` and `log-always` features off. This removes the
`enable-trace-logging` flag from smartplatform/reconciler.

Reviewed By: guswynn

Differential Revision: D30906032

fbshipit-source-id: fdc3e4e29a39e9e181d9f4ff017e6b3e16acdcd8
hawkw pushed a commit that referenced this pull request Mar 18, 2022
This is useful when you need a placeholder subscriber for something.
hawkw pushed a commit that referenced this pull request Mar 18, 2022
This is useful when you need a placeholder subscriber for something.
hawkw added a commit that referenced this pull request Mar 18, 2022
## Motivation

Currently, it is not actually possible to use `set_default(NoCollector)`
or similar to temporarily disable the global default collector (see
#1999).

This is because `NoCollector` is currently used as a placeholder value
when the thread-local cell that stores the current scoped default
collector is initialized. Therefore, we currently check if the current
scoped collector is `NoCollector`, and if it is, we fall back to
returning the global default instead.

This was fine, _when `NoCollector` was a private internal type only_.
However, PR #1549 makes `NoCollector` into a public API type. When users
can publicly construct `NoCollector` instances, it makes sense to want
to be able to use `NoCollector` to disable the current collector. This
is not possible when there is a global default set, because the local
default being `NoCollector` will cause the global default to be
returned.

## Solution

This branch changes the thread-local cell to store an `Option<Dispatch>`
instead, and use the `None` case to indicate no local default is set.
This way, when the local default is explicitly set to `NoCollector`, we
will return `NoCollector` rather than falling back.

This may also be a slight performance improvement, because we now check
if there's no global default by checking if the `Option` is `None`,
rather than downcasting it to a `NoCollector`.

I've also added a test reproducing #1999.

Fixes #1999

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this pull request Mar 18, 2022
## Motivation

Currently, it is not actually possible to use `set_default(NoSubscriber)`
or similar to temporarily disable the global default subscriber (see
#1999).

This is because `NoSubscriber` is currently used as a placeholder value
when the thread-local cell that stores the current scoped default
subscriber is initialized. Therefore, we currently check if the current
scoped subscriber is `NoSubscriber`, and if it is, we fall back to
returning the global default instead.

This was fine, _when `NoSubscriber` was a private internal type only_.
However, PR #1549 makes `NoSubscriber` into a public API type. When users
can publicly construct `NoSubscriber` instances, it makes sense to want
to be able to use `NoSubscriber` to disable the current subscriber. This
is not possible when there is a global default set, because the local
default being `NoSubscriber` will cause the global default to be
returned.

## Solution

This branch changes the thread-local cell to store an `Option<Dispatch>`
instead, and use the `None` case to indicate no local default is set.
This way, when the local default is explicitly set to `NoSubscriber`, we
will return `NoSubscriber` rather than falling back.

This may also be a slight performance improvement, because we now check
if there's no global default by checking if the `Option` is `None`,
rather than downcasting it to a `NoSubscriber`.

I've also added a test reproducing #1999.

Fixes #1999

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this pull request Mar 18, 2022
## Motivation

Currently, it is not actually possible to use `set_default(NoSubscriber)`
or similar to temporarily disable the global default subscriber (see
#1999).

This is because `NoSubscriber` is currently used as a placeholder value
when the thread-local cell that stores the current scoped default
subscriber is initialized. Therefore, we currently check if the current
scoped subscriber is `NoSubscriber`, and if it is, we fall back to
returning the global default instead.

This was fine, _when `NoSubscriber` was a private internal type only_.
However, PR #1549 makes `NoSubscriber` into a public API type. When users
can publicly construct `NoSubscriber` instances, it makes sense to want
to be able to use `NoSubscriber` to disable the current subscriber. This
is not possible when there is a global default set, because the local
default being `NoSubscriber` will cause the global default to be
returned.

## Solution

This branch changes the thread-local cell to store an `Option<Dispatch>`
instead, and use the `None` case to indicate no local default is set.
This way, when the local default is explicitly set to `NoSubscriber`, we
will return `NoSubscriber` rather than falling back.

This may also be a slight performance improvement, because we now check
if there's no global default by checking if the `Option` is `None`,
rather than downcasting it to a `NoSubscriber`.

I've also added a test reproducing #1999.

Fixes #1999

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this pull request Mar 22, 2022
## Motivation

Currently, it is not actually possible to use `set_default(NoSubscriber)`
or similar to temporarily disable the global default subscriber (see
#1999).

This is because `NoSubscriber` is currently used as a placeholder value
when the thread-local cell that stores the current scoped default
subscriber is initialized. Therefore, we currently check if the current
scoped subscriber is `NoSubscriber`, and if it is, we fall back to
returning the global default instead.

This was fine, _when `NoSubscriber` was a private internal type only_.
However, PR #1549 makes `NoSubscriber` into a public API type. When users
can publicly construct `NoSubscriber` instances, it makes sense to want
to be able to use `NoSubscriber` to disable the current subscriber. This
is not possible when there is a global default set, because the local
default being `NoSubscriber` will cause the global default to be
returned.

## Solution

This branch changes the thread-local cell to store an `Option<Dispatch>`
instead, and use the `None` case to indicate no local default is set.
This way, when the local default is explicitly set to `NoSubscriber`, we
will return `NoSubscriber` rather than falling back.

This may also be a slight performance improvement, because we now check
if there's no global default by checking if the `Option` is `None`,
rather than downcasting it to a `NoSubscriber`.

I've also added a test reproducing #1999.

Fixes #1999

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
vkill pushed a commit to bk-rs/fbthrift-git-rs that referenced this pull request Jan 12, 2023
Summary:
This includes recent changes:
- `skip_all` in #[instrument] tokio-rs/tracing#1548
- NoSubscriber no-op Subscriber tokio-rs/tracing#1549
- Box/Arc Layer (tokio-rs/tracing#1536 +
  tokio-rs/tracing#1547)
- log filtering fixes tokio-rs/tracing#1543

Local: force `log` and `log-always` features off. This removes the
`enable-trace-logging` flag from smartplatform/reconciler.

Reviewed By: guswynn

Differential Revision: D30906032

fbshipit-source-id: fdc3e4e29a39e9e181d9f4ff017e6b3e16acdcd8
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request May 22, 2024
tokio-rs#1549)

This is useful when you need a placeholder subscriber for something.
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request May 22, 2024
# 0.1.20 (September 12, 2021)

This release adds support for `f64` as one of the `tracing-core`
primitive field values, allowing floating-point values to be recorded as
typed values rather than with `fmt::Debug`. Additionally, it adds
`NoSubscriber`, a `Subscriber` implementation that does nothing.
### Added

- **subscriber**: `NoSubscriber`, a no-op `Subscriber` implementation
  ([tokio-rs#1549])
- **field**: Added `Visit::record_f64` and support for recording
  floating-point values ([tokio-rs#1507])

Thanks to new contributors @jsgf and @maxburke for contributing to this
release!

[tokio-rs#1549]: tokio-rs#1549
[tokio-rs#1507]: tokio-rs#1507
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request May 22, 2024
# 0.1.27 (September 13, 2021)

This release adds a new [`Span::or_current`] method to aid in
efficiently propagating span contexts to spawned threads or tasks.
Additionally, it updates the [`tracing-core`] version to [0.1.20] and
the [`tracing-attributes`] version to [0.1.16], ensuring that a number
of new features in those crates are present.

### Fixed

- **instrument**: Added missing `WithSubscriber` implementations for
  futures and other types (tokio-rs#1424)

### Added

- `Span::or_current` method, to help with efficient span context
  propagation (tokio-rs#1538)
- **attributes**: add `skip_all` option to `#[instrument]` (tokio-rs#1548)
- **attributes**: record primitive types as primitive values rather than
  as `fmt::Debug` (tokio-rs#1378)
- **core**: `NoSubscriber`, a no-op `Subscriber` implementation
  (tokio-rs#1549)
- **core**: Added `Visit::record_f64` and support for recording
  floating-point values (tokio-rs#1507, tokio-rs#1522)
- A large number of documentation improvements and fixes (tokio-rs#1369,
  tokio-rs#1398, tokio-rs#1435, tokio-rs#1442, tokio-rs#1524, tokio-rs#1556)

Thanks to new contributors @dzvon and @mbergkvist, as well as @teozkr,
@maxburke, @LukeMathWalker, and @jsgf, for contributing to this release!

[`Span::or_current`]: https://docs.rs/tracing/0.1.27/tracing/struct.Span.html#method.or_current
[`tracing-core`]: https://crates.io/crates/tracing-core
[`tracing-attributes`]: https://crates.io/crates/tracing-attributes
[`tracing-core`]: https://crates.io/crates/tracing-core
[0.1.20]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.20
[0.1.16]: https://github.com/tokio-rs/tracing/releases/tag/tracing-attributes-0.1.16
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request May 22, 2024
## Motivation

Currently, it is not actually possible to use `set_default(NoSubscriber)`
or similar to temporarily disable the global default subscriber (see
tokio-rs#1999).

This is because `NoSubscriber` is currently used as a placeholder value
when the thread-local cell that stores the current scoped default
subscriber is initialized. Therefore, we currently check if the current
scoped subscriber is `NoSubscriber`, and if it is, we fall back to
returning the global default instead.

This was fine, _when `NoSubscriber` was a private internal type only_.
However, PR tokio-rs#1549 makes `NoSubscriber` into a public API type. When users
can publicly construct `NoSubscriber` instances, it makes sense to want
to be able to use `NoSubscriber` to disable the current subscriber. This
is not possible when there is a global default set, because the local
default being `NoSubscriber` will cause the global default to be
returned.

## Solution

This branch changes the thread-local cell to store an `Option<Dispatch>`
instead, and use the `None` case to indicate no local default is set.
This way, when the local default is explicitly set to `NoSubscriber`, we
will return `NoSubscriber` rather than falling back.

This may also be a slight performance improvement, because we now check
if there's no global default by checking if the `Option` is `None`,
rather than downcasting it to a `NoSubscriber`.

I've also added a test reproducing tokio-rs#1999.

Fixes tokio-rs#1999

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants