Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracing: don't emit log events if a subscriber has been set (#346)
## Motivation Currently, when `tracing`'s `log` feature is enabled, all spans and events will emit `log` records as well as `tracing` events. When `tracing-log` is being used to convert `log` records into `tracing` events, this results in duplicate events being observed: those emitted by the event macros directly, and those generated from the log records they emit by `tracing-log`. ## Solution In `tracing-core` 0.1.6, we added an internal API for checking if a `tracing` subscriber has ever been set. In addition to the performance optimizations which this was initially intended to enable, this also gives us a way for `tracing` macros in libraries to check if a downstream application that depends on those libraries is actually using `tracing`. If `tracing` is in use and a subscriber has been set, the macros can be disabled. In a handful of cases, users _may_ wish to collect `log` records and `tracing` events totally separately. For example, `log` records might be output to the console while `tracing` is used to generate metrics or for performance profiling. In this case, there is an additional `log-always` feature flag which applications can set to enable all of `tracing`'s log records regardless of whether a subscriber is in use. In most cases where the `log` feature is currently used (libraries that want to emit both `tracing` and `log` diagnostics for their users), this will not be necessary. Fixes #204 Signed-off-by: Eliza Weisman <eliza@buoyant.io>
- Loading branch information
Showing
6 changed files
with
114 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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