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

Migrate internal diagnostics to tracing #655

Merged
merged 3 commits into from
Jul 17, 2020

Conversation

hawkw
Copy link
Contributor

@hawkw hawkw commented Jul 16, 2020

The tracing crate and related libraries provide an interface for Rust
libraries and applications to emit and consume structured, contextual,
and async-aware diagnostic information. tracing is maintained by the
Tokio project and is becoming widely adopted by other libraries in the
stack Warp uses, such as hyper, h2, and tonic and in other
parts of the broader Rust ecosystem.

Tracing supports multiple integrations with the log crate. An adapter
can convert log::Records into tracing::Events to be consumed by a
tracing subscriber, and a tracing feature flag can be enabled to
emit log records from tracing's macros.

However, tracing's system for filtering what spans and events should
be recorded is more efficient than the log crate's filtering in many
cases, since it allows filtering decisions to be cached at the callsite,
avoiding a call to a filtering function that may, for example, perform
string matching. This benefit is only available when events are emitted
natively from tracing's macros, rather than converted by an adapter
from log::Records, because log's records lack static callsites.

This branch migrates Warp's internal diagnostics to use tracing rather
than log. In general, the tracing macros are drop-in compatible with
log, so the migration only requires changing what crate the macros are
imported from. Tracing's "log" feature flag is enabled, causing all the
tracing macros to emit log records if no tracing subscriber has
been set. This means that the logs currently emitted for log users
should be unchanged, while tracing users should see small performance
improvements. I've also added a few tracing spans to provide context
for some of the events Warp emits.

Future work could involve:

  • making the events warp emits more structured, so that they emit
    tracing's structured key-value fields rather than textual messages
  • adding more spans to provide context to Warp's events
  • adding filters for emitting traces from applications (PR Add filters for emitting Tracing diagnostics #656)

Signed-off-by: Eliza Weisman [email protected]

@seanmonstar seanmonstar merged commit 2947680 into seanmonstar:master Jul 17, 2020
jxs pushed a commit to jxs/warp that referenced this pull request Jun 27, 2021
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