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

fmt: Add support for runtime filter reloading #45

Merged
merged 13 commits into from
Apr 10, 2019
Merged

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Apr 6, 2019

This branch adds support for runtime filter reloading to
tokio-trace-fmt. Filters may be reloaded through a Handle
type that can be constructed when the subscriber or filter are
constructed.

In the future, when PR #44 merges, it will also be possible to add a
free function record_current that downcasts and reloads the current
subscriber.

Currently, when using a reloadable filter, Interest is never cached.
When tokio-rs/tokio#1039 is merged, we can invalidate the callsite cache
when reloading, allowing us to cache interests.

Closes #42

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

@hawkw hawkw added kind/feature New feature or request crate/fmt Related to the `tracing-fmt` crate labels Apr 6, 2019
@hawkw hawkw self-assigned this Apr 6, 2019
@hawkw hawkw requested a review from LucioFranco April 6, 2019 19:14
@hawkw
Copy link
Member Author

hawkw commented Apr 6, 2019

This is a draft currently as I have yet to factor out the portion of this change that requires the subscriber downcasting API. I figured I'd ptu it up now as a preview.

@hawkw hawkw marked this pull request as ready for review April 7, 2019 20:29
@hawkw
Copy link
Member Author

hawkw commented Apr 7, 2019

@LucioFranco I've edited this branch to remove the portion of the change that requires downcasting support to land, so this can now be merged into the current master. Thus this branch is now ready for a proper review.

I've separated the changes that require downcasting and will propose them in a follow-up branch.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

This looks great!!! Thank you so much!!!

}
}

impl<F: 'static> ReloadFilter<F> {
Copy link
Member

Choose a reason for hiding this comment

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

im not totally following why this needs 'static?

Copy link
Member Author

Choose a reason for hiding this comment

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

@LucioFranco it's because of the 'static bound on the filter type on the impl of Subscriber for FmtSubscriber:
https://github.com/tokio-rs/tokio-trace-nursery/blob/462a08fb6ca64db3944689ecafdae0107c6982c7/tokio-trace-fmt/src/lib.rs#L83
this is because implementors of Subscriber have to be 'static. So a non-'static filter wouldn't actually be usable.

In retrospect, the 'static bound should probably just be on the Filter trait...

Copy link
Member

Choose a reason for hiding this comment

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

Right, that makes sense, it also makes sense to move it lower into the Filter trait.

tokio-trace-fmt/src/filter/reload.rs Show resolved Hide resolved
hawkw added 13 commits April 10, 2019 11:12
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
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
Copy link
Member Author

hawkw commented Apr 10, 2019

Build failure is due to an unrelated upstream change --- c993cca should fix that.

@hawkw hawkw merged commit 22f6331 into master Apr 10, 2019
hawkw added a commit that referenced this pull request Apr 10, 2019
This branch adds support for runtime filter reloading to
`tokio-trace-fmt`. Filters may be reloaded through a `Handle`
type that can be constructed when the subscriber or filter are
constructed.

In the future, when PR #44 merges, it will also be possible to add a
free function `record_current` that downcasts and reloads the current
subscriber.

Currently, when using a reloadable filter, `Interest` is never cached.
When tokio-rs/tokio#1039 is merged, we can invalidate the callsite cache
when reloading, allowing us to cache interests.

Closes #42

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@hawkw hawkw deleted the eliza/reload-filter branch June 18, 2019 23:57
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/fmt Related to the `tracing-fmt` crate kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants