nagisa / rust_tracy_client

Tracy client libraries for Rust
Apache License 2.0
178 stars 37 forks source link

I want to be able to enable/disable via command line argument #95

Open joaoantoniocardoso opened 9 months ago

joaoantoniocardoso commented 9 months ago

Hi,

I was previously using version 0.10, and I was able to only enable the tracy client if my program received some CLI argument (enable-tracy, for instance).

On version 0.11, it seems to be only possible to enable/disable via feature, which would require my software to be rebuilt.

Is there any approach to that on 0.11?

Just to mention, I was doing (on 0.10), something like:

    // Redirects all gstreamer logs to tracing.
    gst::log::remove_default_log_function();
    // This fundamentally changes the CPU usage of our streams, so we are only enabling
    // this integration if absolutely necessary.
    if cli::manager::is_tracy() {
        tracing_gstreamer::integrate_events(); // This must be called before any gst::init()
        gst::init().unwrap();
        tracing_gstreamer::integrate_spans(); // This must be called after gst::init(), this is necessary to have GStreamer on tracy
    }

and

tracing-tracy = { version = "0.10.4", features = ["ondemand", "broadcast"] }
nagisa commented 9 months ago

You still can have the previous behaviour Check out the manual-lifetime feature.

Note though that unconditionally enabling Tracy may have other effects even if the traces are not being collected due to manual lifetimes. But you will have to read the Tracy code to double check.

24 Feb 2024 01:58:34 João Antônio Cardoso @.***>:

Hi,

I was previously using version 0.10, and I was able to only enable the tracy client if my program received some CLI argument (/enable-tracy/, for instance).

On version 0.11, it seems to be only possible to enable/disable via feature, which would require my software to be rebuilt.

Is there any approach to that on 0.11?

Just to mention, I was doing (on 0.10), something like:

// Redirects all gstreamer logs to tracing.
gst::log::remove_default_log_function();
// This fundamentally changes the CPU usage of our streams, so we are only enabling
// this integration if absolutely necessary.
if cli::manager::is_tracy() {
    tracing_gstreamer::integrate_events(); // This must be called before any gst::init()
    gst::init().unwrap();
    tracing_gstreamer::integrate_spans(), // This must be called after gst::init(), this is necessary to have GStreamer on tracy
}

— Reply to this email directly, view it on GitHub[https://github.com/nagisa/rust_tracy_client/issues/95], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AAFFZUVEOKL6Q7YC3KIKU33YVEUKPAVCNFSM6AAAAABDXQJQRSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE2TCOJXGAZDMOA]. You are receiving this because you are subscribed to this thread. [Tracking image][https://github.com/notifications/beacon/AAFFZUUAVMTGYW7EPZWZPPLYVEUKPA5CNFSM6AAAAABDXQJQRSWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHIARDV3Q.gif]