Skip to content

Commit 01d2b65

Browse files
committed
docs(dev-guide/tracing): make "Adding instrumentation" a level-2 title
1 parent 178c502 commit 01d2b65

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

doc/dev-guide/src/tracing.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,23 @@ And [look in Jaeger for a trace](http://localhost:16686/search?service=rustup).
9494
Tracing can also be used in tests to get a trace of the operations taken during the test.
9595
To 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
109114
spans lightweight can help avoid frequency bias in the results - where
110115
parameters with large debug in frequently called functions show up as much
111116
slower than they are.

0 commit comments

Comments
 (0)