Giter VIP home page Giter VIP logo

Comments (1)

hawkw avatar hawkw commented on August 16, 2024

👍, this would be nice to have.

Here's how I'd probably do it:

  1. We could add a new function to FmtSubscriber that takes a new filter and changes the filter to the previous value.

  2. Then, we could use the subscriber downcasting API that was added in tokio-rs/tokio#974 to invoke that function on the FmtSubscriber. So, when we set the subscriber as the default, we could hold onto a Dispatch pointing to it, and use that to call the function that changes the filter, like this:

    dispatch.downcast_ref::<FmtSubscriber<...>>()
        .expect("Dispatch should still point to FmtSubscriber")
        .set_filter(new_filter);

    We could also provide a free function or something that gets the current default Dispatch, tries to downcast it to a FmtSubscriber, and calls the set_filter function if it is one.

  3. For now, any subscriber which wishes to dynamically change its filter at runtime will need to return Interest::sometimes for all calls to register_callsite, so we would need some way of indicating whether or not this will occur when building the FmtSubscriber. I have some thoughts on how to do that in a type safe way that guarantees the filter won't be modified unless we state that it can.

  4. Furthermore, we might want to consider adding an API to tokio-trace-core to allow completely invalidating and rebuilding all the cached Interests. This would allow the subscriber to return Interest::always and Interest::never, and invalidate the cached values only if the filter changes. This is almost certainly better for performance than re-evaluating the filters every time (although actually changing the filters would be a relatively slow operation). Adding a function like that to -core is tracked by tokio-rs/tokio#1038.

from tracing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.