6262//! The `enter` method enters a span, returning a [guard] that exits the span
6363//! when dropped
6464//! ```
65- //! # #[macro_use] extern crate tracing;
66- //! # use tracing::Level;
65+ //! # use tracing::{Level, span};
6766//! let my_var: u64 = 5;
6867//! let my_span = span!(Level::TRACE, "my_span", my_var);
6968//!
8887//! `in_scope` takes a closure or function pointer and executes it inside the
8988//! span.
9089//! ```
91- //! # #[macro_use] extern crate tracing;
92- //! # use tracing::Level;
90+ //! # use tracing::{Level, span};
9391//! let my_var: u64 = 5;
9492//! let my_span = span!(Level::TRACE, "my_span", my_var = &my_var);
9593//!
122120//! as long as the longest-executing span in its subtree.
123121//!
124122//! ```
125- //! # #[macro_use] extern crate tracing;
126- //! # use tracing::Level;
123+ //! # use tracing::{Level, span};
127124//! // this span is considered the "root" of a new trace tree:
128125//! span!(Level::INFO, "root").in_scope(|| {
129126//! // since we are now inside "root", this span is considered a child
143140//! the `span!` macro. For example:
144141//!
145142//! ```rust
146- //! # #[macro_use] extern crate tracing;
147- //! # use tracing::Level;
143+ //! # use tracing::{Level, span};
148144//! // Create, but do not enter, a span called "foo".
149145//! let foo = span!(Level::INFO, "foo");
150146//!
186182//! _closed_. Consider, for example, a future which has an associated
187183//! span and enters that span every time it is polled:
188184//! ```rust
189- //! # extern crate tracing;
190- //! # extern crate futures;
191185//! # use futures::{Future, Poll, Async};
192186//! struct MyFuture {
193187//! // data
227221//! that handle "closes" the span, since the capacity to enter it no longer
228222//! exists. For example:
229223//! ```
230- //! # #[macro_use] extern crate tracing;
231- //! # use tracing::Level;
224+ //! # use tracing::{Level, span};
232225//! {
233226//! span!(Level::TRACE, "my_span").in_scope(|| {
234227//! // perform some work in the context of `my_span`...
261254//! construct one span and perform the entire loop inside of that span, like:
262255//!
263256//! ```rust
264- //! # #[macro_use] extern crate tracing;
265- //! # use tracing::Level;
257+ //! # use tracing::{Level, span};
266258//! # let n = 1;
267259//! let span = span!(Level::TRACE, "my_loop");
268260//! let _enter = span.enter();
273265//! ```
274266//! Or, should we create a new span for each iteration of the loop, as in:
275267//! ```rust
276- //! # #[macro_use] extern crate tracing;
277- //! # use tracing::Level;
268+ //! # use tracing::{Level, span};
278269//! # let n = 1u64;
279270//! for i in 0..n {
280271//! let span = span!(Level::TRACE, "my_loop", iteration = i);
@@ -721,8 +712,7 @@ impl Span {
721712 /// # Examples
722713 ///
723714 /// ```
724- /// #[macro_use] extern crate tracing;
725- /// # use tracing::Level;
715+ /// # use tracing::{span, Level};
726716 /// let span = span!(Level::INFO, "my_span");
727717 /// let guard = span.enter();
728718 ///
@@ -737,7 +727,7 @@ impl Span {
737727 /// Guards need not be explicitly dropped:
738728 ///
739729 /// ```
740- /// #[macro_use] extern crate tracing;
730+ /// # use tracing::trace_span ;
741731 /// fn my_function() -> String {
742732 /// // enter a span for the duration of this function.
743733 /// let span = trace_span!("my_function");
@@ -759,7 +749,7 @@ impl Span {
759749 /// entered:
760750 ///
761751 /// ```
762- /// #[macro_use] extern crate tracing;
752+ /// # use tracing::{info, info_span} ;
763753 /// let span = info_span!("my_great_span");
764754 ///
765755 /// {
@@ -1073,8 +1063,7 @@ impl Span {
10731063 /// # Examples
10741064 ///
10751065 /// ```
1076- /// # #[macro_use] extern crate tracing;
1077- /// # use tracing::Level;
1066+ /// # use tracing::{trace, span, Level};
10781067 /// let my_span = span!(Level::TRACE, "my_span");
10791068 ///
10801069 /// my_span.in_scope(|| {
0 commit comments