tikv / minitrace-rust

Extremely fast tracing library for Rust
https://github.com/fast/fastrace
Apache License 2.0
731 stars 47 forks source link

#[cfg(test)] args are not IDE friendly #101

Closed breezewish closed 8 months ago

breezewish commented 2 years ago

With latest intellij-rust (14 Feb 2022), the IDE doesn't work well for such functions:

image
Xuanwo commented 2 years ago

How about making it a new function like:

#[cfg(test)]
pub fn root_with_collect(event: &'static str, collect: GlobalCollect) -> (Self, Collector) {}
andylokandy commented 2 years ago

I suspect that the plugin mistakenly set cfg(test) to true for doctest.

taqtiqa-mark commented 2 years ago

I also see this behavior in the VS-Code IDE.

Not sure what the plans are for the collect: parameter.... if it is intended to allow this to be passed-in, in the future, you could have it as an optional parameter for the intervening period (where tests are the only use case):

pub fn root(event: &'static str, collect: Option<GlobalCollect>)

Then default usage would, until that time arrives, be Span::root("root", None)

taqtiqa-mark commented 2 years ago

Collating functions similarly affected: