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

log: LogTracer checks if events are enabled #70

Merged
merged 2 commits into from
Jun 20, 2019

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Jun 20, 2019

Motivation

Currently, the LogTracer adapter in tokio-trace-log does not check
if an event translated from a log record would be enabled by the
current dispatcher, and always dispatches the event. This means that
the tokio-trace subscribers never have the opportunity to filter that
event.

Solution

This branch changes the LogTracer to call enabled on the current
dispatcher before creating an event. Unfortunately, we can't do this in
the log::Log::enabled impl for LogTracer, since the log::Metadata
lacks all the information required to create a tokio_trace::Metadata.

There are some potential improvements that we can make as follow-ups: in
particular, the LogTracer can keep its own cache of log records and
Interests, similar to the callsite cache, to avoid re-evaluating
filters. Additionally, if we add an Event::new (see
tokio-rs/tokio#1149), we can eliminate a redundant thread-local storage
access. I'll open issues for these changes as follow-ups.

Signed-off-by: Eliza Weisman eliza@buoyant.io

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@hawkw hawkw added kind/feature New feature or request crate/log Related to the `tracing-log` crate labels Jun 20, 2019
@hawkw hawkw self-assigned this Jun 20, 2019
@hawkw hawkw merged commit 86985c6 into master Jun 20, 2019
@hawkw hawkw mentioned this pull request Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/log Related to the `tracing-log` crate kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants