Skip to content

Conversation

@samugi
Copy link
Contributor

@samugi samugi commented Jun 30, 2025

Motivation

Resolve #1629 without introducing a breaking change.

A workaround for this issue was introduced via filter_mut, which allows reloading the Filter of a Filtered layer — but it still doesn't support replacing the entire Filtered layer.

A breaking change was also proposed, but it comes with some downsides:

  • It cannot be included in a patch release.
  • As discussed in the Alternatives section here, it could introduce unintended side effects.

Solution

This change adds support for reloading filtered layers without breaking the existing API by introducing a dedicated Handle::reload_filtered method for reloading Filtered layers, and a Layer::on_reload_layer method for performing late initialization when a Layer is reloaded.

Handle::reload_filtered invokes the new Layer::on_reload_layer method on the layer. This method is responsible for registering the filter with the subscriber via register_filter_immut.

Unlike register_filter, the register_filter_immut function takes a shared reference to the subscriber, allowing filter registration after the subscriber has been fully initialized.

Usage examples for are included in the inline documentation.

Fixes: #1629

@samugi samugi requested review from a team and hawkw as code owners June 30, 2025 13:15
@samugi samugi force-pushed the fix/reload-filtered-layers branch 2 times, most recently from cad5db4 to 6316fba Compare July 2, 2025 12:57
This commit adds support for reloading filtered layers without breaking
the existing API.

The `Reload` handle now provides a `reload_filtered` function, which
invokes a newly introduced `on_reload_layer` function on the `Layer`.
This function is responsible for registering the filter with the
subscriber via `register_filter_immut`.

Unlike `register_filter`, `register_filter_immut` takes a shared
reference to the subscriber, allowing the filter registration to occur
after the subscriber has been fully initialized.
@samugi samugi force-pushed the fix/reload-filtered-layers branch from 6316fba to 5f93bac Compare November 19, 2025 11:03
@hds hds added kind/feature New feature or request crate/subscriber Related to the `tracing-subscriber` crate needs/review labels Nov 22, 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/feature New feature or request needs/review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic after reloading layer, combined with .with_filter

2 participants