-
Notifications
You must be signed in to change notification settings - Fork 844
fix(subscriber): make Layered propagate on_register_dispatch #3379
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
base: main
Are you sure you want to change the base?
fix(subscriber): make Layered propagate on_register_dispatch #3379
Conversation
|
It seems like this was overlooked in #2269 |
b8ddabe to
a86f408
Compare
hds
left a comment
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.
Thanks for your PR! I've got a couple of comments.
| } | ||
| } | ||
|
|
||
| impl Subscriber for TestLayer { |
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.
What do you think about extending the MockSubscriebr and MockLayer in tracing-mock to allow expecting on_register_dispatch?
| S: Subscriber, | ||
| { | ||
| fn on_register_dispatch(&self, subscriber: &Dispatch) { | ||
| self.layer.on_register_dispatch(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.
I think we probably want to switch the order here, so that the actual subscriber gets the chance to register first.
a86f408 to
77aedec
Compare
hds
left a comment
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.
Looking great. Thank you! I've got one Question.
| /// [`tracing::subscriber::set_global_default`], so explicitly expecting | ||
| /// this is not usually necessary. However, it may be useful when testing | ||
| /// custom layer implementations that manually call `on_register_dispatch`. | ||
| /// |
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.
Is it possible to add a negative case here?
If not (or not easily) that's fine. Thank you for enhancing tracing-mock!
Motivation
The
Layeredimplementation ofSubscriberdoes not implement and propagate theon_register_dispatchcallback. This means that combined layers will never have theiron_register_dispatchmethods called.Solution
Implement the missing
on_register_dispatchmethod.