@@ -94,18 +94,23 @@ And [look in Jaeger for a trace](http://localhost:16686/search?service=rustup).
9494Tracing can also be used in tests to get a trace of the operations taken during the test.
9595To use this feature, build the project with ` --features=otel,test ` .
9696
97- ### Adding instrumentation
97+ ## Adding instrumentation
9898
99- The ` otel ` feature uses conditional compilation to only add function instrument
100- when enabled. Instrumenting a currently uninstrumented function is mostly simply
101- done like so:
99+ Instrumenting a currently uninstrumented function is mostly simply done like so:
102100
103101``` rust
104102#[tracing:: instrument(level = " trace" , err(level = " trace" ), skip_all)]
105103```
106104
107- ` skip_all ` is not required, but some core structs don't implement Debug yet, and
108- others have a lot of output in Debug : tracing adds some overheads, so keeping
105+ Sometimes you might want to instrument a function only when the ` otel ` feature is enabled.
106+ In this case, you will need to use conditional compilation with ` cfg_attr ` :
107+
108+ ``` rust
109+ #[cfg_attr(feature= " otel" , tracing:: instrument(level = " trace" , err(level = " trace" ), skip_all))]
110+ ```
111+
112+ ` skip_all ` is not required, but some core structs don't implement ` Debug ` yet, and
113+ others have a lot of output in ` Debug ` : tracing adds some overheads, so keeping
109114spans lightweight can help avoid frequency bias in the results - where
110115parameters with large debug in frequently called functions show up as much
111116slower than they are.
0 commit comments