-
Notifications
You must be signed in to change notification settings - Fork 744
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
mock: move subscriber mock from tracing-subscriber tests #2369
Conversation
The `tracing-subscriber` module `tests::support` included functionality to mock a subscriber (via the `Subscribe` trait). This code depends on some items from `tracing_mock::collector` which should otherwise not be public. This change moves the mocking functionality inside `tracing-mock` behind a feature flag. Allowing the `Expect` enum and `MockHandle::new` from `tracing_mock::collector` to be made `pub(crate)` instead of `pub`. Since it's now used from two different modules, the `Expect` enum has been moved to its own module. This requires a lot of modifications to imports so that we're not doing wildcard imports from another crate (i.e. in `tracing-subscriber` importing wildcards from `tracing-mock`). Closes: #2359
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall, this is great --- it's definitely much nicer to have everything all in the same place! i commented on a couple very small nits.
The subscriber feature is included directly by using the `tracing-subscriber` feature (for the optional depedency).
There was a problem hiding this 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!
@@ -10,8 +10,7 @@ pub mod field; | |||
mod metadata; | |||
pub mod span; | |||
|
|||
#[cfg(feature = "subscriber")] | |||
#[doc(hidden)] | |||
#[cfg(feature = "tracing-subscriber")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably also globally enable the doc_cfg
feature flag for this crate so that the feature flags show up in RustDoc, but we can do that separately when we actually...add documentation...before releasing.
There has been interest around publishing `tracing-mock` to crates.io for some time. In order to make this possible, documentation and some code clean up is needed. This change adds documentation to the collector module itself and to all the public APIs in the module. This includes doctests on all the methods that serve as examples. Additionally the implementation for the `Expect` struct has been moved into the module with the definition, this was missed in #2369.
There has been interest around publishing `tracing-mock` to crates.io for some time. In order to make this possible, documentation and some code clean up is needed. This change adds documentation to the collector module itself and to all the public APIs in the module. This includes doctests on all the methods that serve as examples. Additionally the implementation for the `Expect` struct has been moved into the module with the definition, this was missed in #2369. Refs: #539
The `tracing-subscriber` module `tests::support` included functionality to mock a subscriber (via the `Subscribe` trait). This code depends on some items from `tracing_mock::collector` which should otherwise not be public. This change moves the mocking functionality inside `tracing-mock` behind a feature flag. Allowing the `Expect` enum and `MockHandle::new` from `tracing_mock::collector` to be made `pub(crate)` instead of `pub`. Since it's now used from two different modules, the `Expect` enum has been moved to its own module. This requires a lot of modifications to imports so that we're not doing wildcard imports from another crate (i.e. in `tracing-subscriber` importing wildcards from `tracing-mock`). Closes: #2359
The `tracing-subscriber` module `tests::support` included functionality to mock a layer (via the `Layer` trait). This code depends on some items from `tracing_mock::collector` which should otherwise not be public. This change moves the mocking functionality inside `tracing-mock` behind a feature flag. Allowing the `Expect` enum and `MockHandle::new` from `tracing_mock::collector` to be made `pub(crate)` instead of `pub`. Since it's now used from two different modules, the `Expect` enum has been moved to its own module. This requires a lot of modifications to imports so that we're not doing wildcard imports from another crate (i.e. in `tracing-subscriber` importing wildcards from `tracing-mock`). This PR is based on @hds' PR #2369, but modified to track renamings. I also deleted all the doc comments temporarily because updating them was a lot of work and I need to get a release of `tracing-subscriber` out first. Closes: #2359
The `tracing-subscriber` module `tests::support` included functionality to mock a layer (via the `Layer` trait). This code depends on some items from `tracing_mock::collector` which should otherwise not be public. This change moves the mocking functionality inside `tracing-mock` behind a feature flag. Allowing the `Expect` enum and `MockHandle::new` from `tracing_mock::collector` to be made `pub(crate)` instead of `pub`. Since it's now used from two different modules, the `Expect` enum has been moved to its own module. This requires a lot of modifications to imports so that we're not doing wildcard imports from another crate (i.e. in `tracing-subscriber` importing wildcards from `tracing-mock`). This PR is based on @hds' PR #2369, but modified to track renamings. I also deleted all the doc comments temporarily because updating them was a lot of work and I need to get a release of `tracing-subscriber` out first. Closes: #2359
There has been interest around publishing `tracing-mock` to crates.io for some time. In order to make this possible, documentation and some code clean up is needed. This change adds documentation to the collector module itself and to all the public APIs in the module. This includes doctests on all the methods that serve as examples. Additionally the implementation for the `Expect` struct has been moved into the module with the definition, this was missed in #2369. Refs: #539
There has been interest around publishing `tracing-mock` to crates.io for some time. In order to make this possible, documentation and some code clean up is needed. This change adds documentation to the collector module itself and to all the public APIs in the module. This includes doctests on all the methods that serve as examples. Additionally the implementation for the `Expect` struct has been moved into the module with the definition, this was missed in #2369. Refs: #539
There has been interest around publishing `tracing-mock` to crates.io for some time. In order to make this possible, documentation and some code clean up is needed. This change adds documentation to the collector module itself and to all the public APIs in the module. This includes doctests on all the methods that serve as examples. Additionally the implementation for the `Expect` struct has been moved into the module with the definition, this was missed in #2369. Refs: #539
There has been interest around publishing `tracing-mock` to crates.io for some time. In order to make this possible, documentation and some code clean up is needed. This change adds documentation to the collector module itself and to all the public APIs in the module. This includes doctests on all the methods that serve as examples. Additionally the implementation for the `Expect` struct has been moved into the module with the definition, this was missed in #2369. Refs: #539
There has been interest around publishing `tracing-mock` to crates.io for some time. In order to make this possible, documentation and some code clean up is needed. This change adds documentation to the collector module itself and to all the public APIs in the module. This includes doctests on all the methods that serve as examples. Additionally the implementation for the `Expect` struct has been moved into the module with the definition, this was missed in #2369. Refs: #539
There has been interest around publishing `tracing-mock` to crates.io for some time. In order to make this possible, documentation and some code clean up is needed. This change adds documentation to the collector module itself and to all the public APIs in the module. This includes doctests on all the methods that serve as examples. Additionally the implementation for the `Expect` struct has been moved into the module with the definition, this was missed in #2369. Refs: #539
The `tracing-subscriber` module `tests::support` included functionality to mock a layer (via the `Layer` trait). This code depends on some items from `tracing_mock::collector` which should otherwise not be public. This change moves the mocking functionality inside `tracing-mock` behind a feature flag. Allowing the `Expect` enum and `MockHandle::new` from `tracing_mock::collector` to be made `pub(crate)` instead of `pub`. Since it's now used from two different modules, the `Expect` enum has been moved to its own module. This requires a lot of modifications to imports so that we're not doing wildcard imports from another crate (i.e. in `tracing-subscriber` importing wildcards from `tracing-mock`). This PR is based on @hds' PR tokio-rs#2369, but modified to track renamings. I also deleted all the doc comments temporarily because updating them was a lot of work and I need to get a release of `tracing-subscriber` out first. Closes: tokio-rs#2359
There has been interest around publishing `tracing-mock` to crates.io for some time. In order to make this possible, documentation and some code clean up is needed. This change adds documentation to the collector module itself and to all the public APIs in the module. This includes doctests on all the methods that serve as examples. Additionally the implementation for the `Expect` struct has been moved into the module with the definition, this was missed in tokio-rs#2369. Refs: tokio-rs#539
Motivation
The
tracing-subscriber
moduletests::support
included functionality to mock a subscriber (via theSubscribe
trait). This code depends on some items fromtracing_mock::collector
which should otherwise not be public.Solution
This change moves the mocking functionality inside
tracing-mock
behind a feature flag. Allowing theExpect
enum andMockHandle::new
fromtracing_mock::collector
to be madepub(crate)
instead ofpub
. Since it's now used from two different modules, theExpect
enum has been moved to its own module.This requires a lot of modifications to imports so that we're not doing wildcard imports from another crate (i.e. in
tracing-subscriber
importing wildcards fromtracing-mock
).Closes: #2359