Skip to content

Conversation

@bantonsson
Copy link
Contributor

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
Contributor Author

It seems like this was overlooked in #2269

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.

@hds hds added kind/bug Something isn't working crate/subscriber Related to the `tracing-subscriber` crate labels Nov 20, 2025
@bantonsson bantonsson force-pushed the ban/make-layered-propagate-on-register-dispatch branch from a86f408 to 77aedec Compare November 21, 2025 14:57
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.

Looking great. Thank you! I've got one Question.

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 you for all your work on this PR!

I'm preparing some releases and I wanted to get this in first, so I'm merging now. Thanks again!

@hds hds merged commit 8bc008c into tokio-rs:main Nov 24, 2025
55 checks passed
@bantonsson
Copy link
Contributor Author

Seems I was just a few minutes late with the negative test. I'll open a separate PR.

@bantonsson
Copy link
Contributor Author

#3415

hds added a commit that referenced this pull request Nov 24, 2025
In order to add a regression test, #3379 added support to `tracing-mock`
to expect calls to `on_register_dispatch` for both mock subscribers and
mock layers. A negative integration test for the layer case was included
in #3415. However, there are no negative doctests for this (and as per
my own suggestion, there's no negative test for the subscriber method
either as I wasn't sure it was possible).

After a bit of thought, I realised that we could include a negative test
for the `MockSubscriber`. This change adds that test as a doctest, since
we have those in almost all of our documentation and also includes the
already written negative test for the `MockLayer` to a doctest.
hds added a commit that referenced this pull request Nov 24, 2025
## Motivation

In order to add a regression test, #3379 added support to `tracing-mock`
to expect calls to `on_register_dispatch` for both mock subscribers and
mock layers. A negative integration test for the layer case was included
in #3415. However, there are no negative doctests for this (and as per
my own suggestion, there's no negative test for the subscriber method
either as I wasn't sure it was possible).

## Solution

After a bit of thought, I realised that we could include a negative test
for the `MockSubscriber`. This change adds that test as a doctest, since
we have those in almost all of our documentation and also includes the
already written negative test for the `MockLayer` to a doctest.
hds added a commit that referenced this pull request Nov 25, 2025
# 0.3.21 (November 30, 2025)

### Fixed

- Change registry exit to decrement local span ref only ([#3331])
- Make Layered propagate `on_register_dispatch` ([#3379])

### Performance

- Remove `clone_span` on enter (#3289)

### Documented

- Fix a few small things in the format module ([#3339])
- Fix extra closing brace in layer docs ([#3350])
- Fix link in `FmtSpan` docs ([#3411])

[#3331]: https://github.com/tokio-rs/tracing/pull/#3331
[#3339]: https://github.com/tokio-rs/tracing/pull/#3339
[#3350]: https://github.com/tokio-rs/tracing/pull/#3350
[#3379]: https://github.com/tokio-rs/tracing/pull/#3379
[#3411]: https://github.com/tokio-rs/tracing/pull/#3411
hds added a commit that referenced this pull request Nov 25, 2025
# 0.3.21 (November 30, 2025)

### Fixed

- Change registry exit to decrement local span ref only ([#3331])
- Make Layered propagate `on_register_dispatch` ([#3379])

### Performance

- Remove `clone_span` on enter ([#3289])

### Documented

- Fix a few small things in the format module ([#3339])
- Fix extra closing brace in layer docs ([#3350])
- Fix link in `FmtSpan` docs ([#3411])

[#3289]: https://github.com/tokio-rs/tracing/pull/#3289
[#3331]: https://github.com/tokio-rs/tracing/pull/#3331
[#3339]: https://github.com/tokio-rs/tracing/pull/#3339
[#3350]: https://github.com/tokio-rs/tracing/pull/#3350
[#3379]: https://github.com/tokio-rs/tracing/pull/#3379
[#3411]: https://github.com/tokio-rs/tracing/pull/#3411
hds added a commit that referenced this pull request Nov 25, 2025
# 0.3.21 (November 30, 2025)

### Fixed

- Change registry exit to decrement local span ref only ([#3331])
- Make Layered propagate `on_register_dispatch` ([#3379])

### Performance

- Remove `clone_span` on enter ([#3289])

### Documented

- Fix a few small things in the format module ([#3339])
- Fix extra closing brace in layer docs ([#3350])
- Fix link in `FmtSpan` docs ([#3411])

[#3289]: https://github.com/tokio-rs/tracing/pull/#3289
[#3331]: https://github.com/tokio-rs/tracing/pull/#3331
[#3339]: https://github.com/tokio-rs/tracing/pull/#3339
[#3350]: https://github.com/tokio-rs/tracing/pull/#3350
[#3379]: https://github.com/tokio-rs/tracing/pull/#3379
[#3411]: https://github.com/tokio-rs/tracing/pull/#3411
hds added a commit that referenced this pull request Nov 26, 2025
# 0.3.21 (November 26, 2025)

### Fixed

- Change registry exit to decrement local span ref only ([#3331])
- Make Layered propagate `on_register_dispatch` ([#3379])

### Changed

- `tracing`: updated to 0.1.42 ([#3418])

### Performance

- Remove `clone_span` on enter ([#3289])

### Documented

- Fix a few small things in the format module ([#3339])
- Fix extra closing brace in layer docs ([#3350])
- Fix link in `FmtSpan` docs ([#3411])

[#3289]: https://github.com/tokio-rs/tracing/pull/#3289
[#3331]: https://github.com/tokio-rs/tracing/pull/#3331
[#3339]: https://github.com/tokio-rs/tracing/pull/#3339
[#3350]: https://github.com/tokio-rs/tracing/pull/#3350
[#3379]: https://github.com/tokio-rs/tracing/pull/#3379
[#3411]: https://github.com/tokio-rs/tracing/pull/#3411
[#3418]: https://github.com/tokio-rs/tracing/pull/#3418
hds added a commit that referenced this pull request Nov 26, 2025
# 0.3.21 (November 26, 2025)

### Fixed

- Change registry exit to decrement local span ref only ([#3331])
- Make Layered propagate `on_register_dispatch` ([#3379])

### Changed

- `tracing`: updated to 0.1.42 ([#3418])

### Performance

- Remove `clone_span` on enter ([#3289])

### Documented

- Fix a few small things in the format module ([#3339])
- Fix extra closing brace in layer docs ([#3350])
- Fix link in `FmtSpan` docs ([#3411])

[#3289]: https://github.com/tokio-rs/tracing/pull/#3289
[#3331]: https://github.com/tokio-rs/tracing/pull/#3331
[#3339]: https://github.com/tokio-rs/tracing/pull/#3339
[#3350]: https://github.com/tokio-rs/tracing/pull/#3350
[#3379]: https://github.com/tokio-rs/tracing/pull/#3379
[#3411]: https://github.com/tokio-rs/tracing/pull/#3411
[#3418]: https://github.com/tokio-rs/tracing/pull/#3418
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