Skip to content

Conversation

@bantonsson
Copy link

Motivation

The Layered implementation of Subscriber does not implement and propagate the on_register_dispatch callback. This means that combined layers will never have their on_register_dispatch methods called.

Solution

Implement the missing on_register_dispatch method.

@bantonsson bantonsson requested review from a team and hawkw as code owners September 19, 2025 12:00
@bantonsson
Copy link
Author

It seems like this was overlooked in #2269

@bantonsson bantonsson force-pushed the ban/make-layered-propagate-on-register-dispatch branch from b8ddabe to a86f408 Compare November 5, 2025 10:10
Copy link
Contributor

@hds hds left a 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 {
Copy link
Contributor

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);
Copy link
Contributor

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.

@hds hds added kind/bug Something isn't working crate/subscriber Related to the `tracing-subscriber` crate labels Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

crate/subscriber Related to the `tracing-subscriber` crate kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants