/
tracing-demo.rs
54 lines (41 loc) · 1.16 KB
/
tracing-demo.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::thread;
use std::time::Duration;
use tracing_subscriber::prelude::*;
// cargo run --example tracing-demo
fn main() {
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(sentry_tracing::layer())
.try_init()
.unwrap();
let _sentry = sentry::init(sentry::ClientOptions {
release: sentry::release_name!(),
traces_sample_rate: 1.0,
debug: true,
..Default::default()
});
tracing::debug!("System is booting");
tracing::info!("System is booting");
main_span1();
thread::sleep(Duration::from_millis(100));
}
#[tracing::instrument]
fn main_span1() {
thread::sleep(Duration::from_millis(50));
tracing::warn!("System is warning");
thread::spawn(move || {
thread::sleep(Duration::from_millis(50));
thread_span1();
tracing::error!("Holy shit everything is on fire!");
});
thread::sleep(Duration::from_millis(100));
main_span2()
}
#[tracing::instrument]
fn thread_span1() {
thread::sleep(Duration::from_millis(200));
}
#[tracing::instrument]
fn main_span2() {
thread::sleep(Duration::from_millis(200));
}