Avoiding panic on profiling::scope! when profiling not enabled

Currently, calling profiling::scope! causes a panic if Tracy is present but not enabled. That macro apparently calls "span", which, in current versions of tracy-client (although not older ones) is documented as causing a panic if a Tracy client is not running. I think this feature was introduced when Tracy was modified so that you have to start it explicitly; it used to start automatically if compiled in.

So how can I disable Tracy tracing for production without putting #cfg around every call to profiling::scope!?

I don't know anything about the crates involved, but this seems like something that in the worst case is pretty well suited to a macro_rules macro:

macro_rules! scope {
    ($($tok:tt)*) => {
        #[cfg(...)] ::profiling::scope!( $($tok)* )

Right. I'd expected there would be something like that built in already.
This may be a conflict between the profiling crate and the Tracy system not being coordinated.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.