Skip to content

Commit bdbaf80

Browse files
authored
examples: add note to examples that they are for tracing 0.2.0 (#3099)
It is not uncommon that users who are new to tracing look at the examples in the `master` branch of the repository and find that they don't compile. This is because they are examples which compile with the code from the master branch, which is for the as yet unreleased tracing 0.2.0 ecosystem. Users should instead go to the `v0.1.x` branch to find examples compatible with the crates published on crates.io. This change adds a doc-comment to the beginning of every example file informing the user of this fact and suggesting that they check out the `v0.1.x` branch instead.
1 parent 2d30094 commit bdbaf80

39 files changed

+139
-44
lines changed

examples/examples/all-levels.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
use tracing::Level;
24

35
#[no_mangle]

examples/examples/appender-multifile.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! This example demonstrates the use of multiple files with
25
//! `tracing-appender`'s `RollingFileAppender`
3-
//!
46
use tracing_appender::rolling;
57
use tracing_subscriber::fmt::writer::MakeWriterExt;
68

examples/examples/async-fn.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! Demonstrates using the `trace` attribute macro to instrument `async`
25
//! functions.
36
//!

examples/examples/attrs-args.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24

35
use tracing::{debug, info};

examples/examples/attrs-basic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24

35
use tracing::{debug, info, span, Level};

examples/examples/attrs-literal-field-names.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24

35
use tracing::{debug, span, Level};

examples/examples/counters.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24

35
use tracing::{

examples/examples/custom-error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! This example demonstrates using the `tracing-error` crate's `SpanTrace` type
25
//! to attach a trace context to a custom error type.
36
#![deny(rust_2018_idioms)]

examples/examples/echo.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! A "hello world" echo server [from Tokio][echo-example]
25
//!
36
//! This server will create a TCP listener, accept connections in a loop, and

examples/examples/fmt-compact.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24
#[path = "fmt/yak_shave.rs"]
35
mod yak_shave;

examples/examples/fmt-custom-event.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24
#[path = "fmt/yak_shave.rs"]
35
mod yak_shave;

examples/examples/fmt-custom-field.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! This example demonstrates overriding the way `tracing-subscriber`'s
25
//! `FmtSubscriber` formats fields on spans and events, using a closure.
36
//!

examples/examples/fmt-json.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24
#[path = "fmt/yak_shave.rs"]
35
mod yak_shave;

examples/examples/fmt-multiple-writers.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! An example demonstrating how `fmt::Subcriber` can write to multiple
25
//! destinations (in this instance, `stdout` and a file) simultaneously.
36

examples/examples/fmt-pretty.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24
#[path = "fmt/yak_shave.rs"]
35
mod yak_shave;

examples/examples/fmt-source-locations.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! Demonstrates displaying events' source code locations with the `fmt`
25
//! subscriber.
36
#![deny(rust_2018_idioms)]

examples/examples/fmt-stderr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24
use std::io;
35
use tracing::error;

examples/examples/fmt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24
#[path = "fmt/yak_shave.rs"]
35
mod yak_shave;

examples/examples/fmt/yak_shave.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
use snafu::{ResultExt, Snafu};
25
use std::error::Error;
36
use thiserror::Error;

examples/examples/futures-proxy-server.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! A proxy that forwards data to another server and forwards that server's
25
//! responses back to clients.
36
//!

examples/examples/hyper-echo.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24

35
use http::{Method, Request, Response, StatusCode};

examples/examples/inferno-flame.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
use std::{
24
env,
35
fs::File,

examples/examples/instrumented-error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! This example demonstrates using the `tracing-error` crate's `SpanTrace` type
25
//! to attach a trace context to a custom error type.
36
#![deny(rust_2018_idioms)]

examples/examples/journald.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24
use tracing::{error, info};
35
use tracing_subscriber::prelude::*;

examples/examples/log.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
fn main() {
24
tracing_subscriber::fmt()
35
.with_max_level(tracing::Level::TRACE)

examples/examples/map-traced-error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! An example on composing errors inside of a `TracedError`, such that the
25
//! SpanTrace captured is captured when creating the inner error, but still wraps
36
//! the outer error.

examples/examples/panic_hook.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! This example demonstrates how `tracing` events can be recorded from within a
25
//! panic hook, capturing the span context in which the program panicked.
36
//!

examples/examples/serde-yak-shave.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
use std::sync::atomic::{AtomicUsize, Ordering};
24

35
use tracing::debug;

examples/examples/sloggish/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! A simple example demonstrating how one might implement a custom
25
//! collector.
36
//!

examples/examples/sloggish/sloggish_collector.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
use nu_ansi_term::{Color, Style};
24
use tracing::{
35
field::{Field, Visit},

examples/examples/spawny-thing.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//! This is a example showing how information is scoped.
4+
//!
5+
//! You can run this example by running the following command in a terminal
6+
//!
7+
//! ```
8+
//! cargo run --example spawny_thing
9+
//! ```
110
#![deny(rust_2018_idioms)]
211

3-
/// This is a example showing how information is scoped.
4-
///
5-
/// You can run this example by running the following command in a terminal
6-
///
7-
/// ```
8-
/// cargo run --example spawny_thing
9-
/// ```
1012
use futures::future::join_all;
1113
use std::error::Error;
1214
use tracing::{debug, info};

examples/examples/subscriber-filter.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
#![deny(rust_2018_idioms)]
24
#[path = "fmt/yak_shave.rs"]
35
mod yak_shave;

examples/examples/thread-info.rs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
4+
//! This is a example showing how thread info can be displayed when
5+
//! formatting events with `tracing_subscriber::fmt`. This is useful
6+
//! as `tracing` spans can be entered by multiple threads concurrently,
7+
//! or move across threads freely.
8+
//!
9+
//! You can run this example by running the following command in a terminal
10+
//!
11+
//! ```
12+
//! cargo run --example thread-info
13+
//! ```
14+
//!
15+
//! Example output:
16+
//!
17+
//! ```not_rust
18+
//! Jul 17 00:38:07.177 INFO ThreadId(02) thread_info: i=9
19+
//! Jul 17 00:38:07.177 INFO thread 1 ThreadId(03) thread_info: i=9
20+
//! Jul 17 00:38:07.177 INFO large name thread 2 ThreadId(04) thread_info: i=9
21+
//! ```
122
#![deny(rust_2018_idioms)]
2-
/// This is a example showing how thread info can be displayed when
3-
/// formatting events with `tracing_subscriber::fmt`. This is useful
4-
/// as `tracing` spans can be entered by multiple threads concurrently,
5-
/// or move across threads freely.
6-
///
7-
/// You can run this example by running the following command in a terminal
8-
///
9-
/// ```
10-
/// cargo run --example thread-info
11-
/// ```
12-
///
13-
/// Example output:
14-
///
15-
/// ```not_rust
16-
/// Jul 17 00:38:07.177 INFO ThreadId(02) thread_info: i=9
17-
/// Jul 17 00:38:07.177 INFO thread 1 ThreadId(03) thread_info: i=9
18-
/// Jul 17 00:38:07.177 INFO large name thread 2 ThreadId(04) thread_info: i=9
19-
/// ```
2023
use std::thread;
2124
use std::time::Duration;
2225
use tracing::info;

examples/examples/toggle-subscribers.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
4+
//! This is a example showing how `Subscriber`s can be enabled or disabled by
5+
//! by wrapping them with an `Option`. This example shows `fmt` and `json`
6+
//! being toggled based on the `json` command line flag.
7+
//!
8+
//! You can run this example by running the following command in a terminal
9+
//!
10+
//! ```
11+
//! cargo run --example toggle-subscribers -- --json
12+
//! ```
13+
//!
114
#![deny(rust_2018_idioms)]
2-
/// This is a example showing how `Subscriber`s can be enabled or disabled by
3-
/// by wrapping them with an `Option`. This example shows `fmt` and `json`
4-
/// being toggled based on the `json` command line flag.
5-
///
6-
/// You can run this example by running the following command in a terminal
7-
///
8-
/// ```
9-
/// cargo run --example toggle-subscribers -- --json
10-
/// ```
11-
///
1215
use argh::FromArgs;
1316
use tracing::info;
1417
use tracing_subscriber::{subscribe::CollectExt, util::SubscriberInitExt};

examples/examples/tokio-spawny-thing.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
4+
//! This is a example showing how information is scoped with tokio's
5+
//! `task::spawn`.
6+
//!
7+
//! You can run this example by running the following command in a terminal
8+
//!
9+
//! ```
10+
//! cargo run --example tokio-spawny-thing
11+
//! ```
112
#![deny(rust_2018_idioms)]
2-
/// This is a example showing how information is scoped with tokio's
3-
/// `task::spawn`.
4-
///
5-
/// You can run this example by running the following command in a terminal
6-
///
7-
/// ```
8-
/// cargo run --example tokio-spawny-thing
9-
/// ```
1013
use futures::future::try_join_all;
1114
use tracing::{debug, info, instrument, span, Instrument as _, Level};
1215

examples/examples/tokio_panic_hook.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! This example demonstrates that a custom panic hook can be used to log panic
25
//! messages even when panics are captured (such as when a Tokio task panics).
36
//!

examples/examples/tower-client.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
use http::{Method, Request, Uri};
24
use hyper::{client::Client, Body};
35
use std::time::Duration;

examples/examples/tower-load.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
3+
//!
14
//! A demo showing how filtering on values and dynamic filter reloading can be
25
//! used together to help make sense of complex or noisy traces.
36
//!

examples/examples/tower-server.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
2+
//! release examples, please see the `v0.1.x` branch instead.
13
use futures::future;
24
use http::{Request, Response};
35
use hyper::{Body, Server};

0 commit comments

Comments
 (0)