Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In some cases, users may wish to erase the type of a `Colelct` implementation, such as when it is dynamically constructed from a complex parameterized type. When doing so, it's important to ensure that all trait methods with default implementations are properly forwarded to the inner erased type. For example, if the type does not implement `try_close`, but the inner erased collector does, then the the collector will not be notified when spans close — which could result in a memory leak. To avoid potential footguns resulting from users implementing type-erased collectors incorrectly, this branch adds a new `impl Collect for Box<dyn Collect + Send + Sync + 'static>` in `tracing-core`, when the `alloc` feature flag is enabled. This is also somewhat more ergonomic than any solution in another crate, since the implementation is for `Box<dyn Collect + ...>` directly, rather than some `BoxedCollector` newtype.
- Loading branch information