mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-07 09:45:15 +00:00
docs: fix incorrect explanation for futures and spans (#531)
This commit is contained in:
parent
f7b338ed7c
commit
8214570c44
@ -201,10 +201,11 @@ async {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The span `_s` will be dropped at the end of the `async` block, _not_ when the
|
The span guard `_s` will not exit until the future generated by the `async` block is complete.
|
||||||
future created by the async block is complete. In practice, this means that
|
Since futures and spans can be entered and exited _multiple_ times without them completing,
|
||||||
the span does not live long enough to instrument the future for its entire
|
the span remains entered for as long as the future exists, rather than being entered only when
|
||||||
lifetime.
|
it is polled, leading to very confusing and incorrect output.
|
||||||
|
For more details, see [the documentation on closing spans](https://tracing.rs/tracing/span/index.html#closing-spans).
|
||||||
|
|
||||||
There are two ways to instrument asynchronous code. The first is through the
|
There are two ways to instrument asynchronous code. The first is through the
|
||||||
[`Future::instrument`](https://docs.rs/tracing-futures/0.2.0/tracing_futures/trait.Instrument.html#method.instrument) combinator:
|
[`Future::instrument`](https://docs.rs/tracing-futures/0.2.0/tracing_futures/trait.Instrument.html#method.instrument) combinator:
|
||||||
|
@ -216,10 +216,11 @@ async {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The span `_s` will be dropped at the end of the `async` block, _not_ when the
|
The span guard `_s` will not exit until the future generated by the `async` block is complete.
|
||||||
future created by the async block is complete. In practice, this means that
|
Since futures and spans can be entered and exited _multiple_ times without them completing,
|
||||||
the span does not live long enough to instrument the future for its entire
|
the span remains entered for as long as the future exists, rather than being entered only when
|
||||||
lifetime.
|
it is polled, leading to very confusing and incorrect output.
|
||||||
|
For more details, see [the documentation on closing spans](https://tracing.rs/tracing/span/index.html#closing-spans).
|
||||||
|
|
||||||
There are two ways to instrument asynchronous code. The first is through the
|
There are two ways to instrument asynchronous code. The first is through the
|
||||||
[`Future::instrument`](https://docs.rs/tracing-futures/0.2.0/tracing_futures/trait.Instrument.html#method.instrument) combinator:
|
[`Future::instrument`](https://docs.rs/tracing-futures/0.2.0/tracing_futures/trait.Instrument.html#method.instrument) combinator:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user