forked from open-telemetry/opentelemetry-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzipkin.rs
More file actions
28 lines (24 loc) · 687 Bytes
/
zipkin.rs
File metadata and controls
28 lines (24 loc) · 687 Bytes
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
use opentelemetry::{
global::{self},
trace::{Span, Tracer},
};
use std::thread;
use std::time::Duration;
fn bar() {
let tracer = global::tracer("component-bar");
let mut span = tracer.start("bar");
thread::sleep(Duration::from_millis(6));
span.end()
}
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
let (tracer, provider) = opentelemetry_zipkin::new_pipeline()
.with_service_name("trace-demo")
.install_simple()?;
tracer.in_span("foo", |_cx| {
thread::sleep(Duration::from_millis(6));
bar();
thread::sleep(Duration::from_millis(6));
});
provider.shutdown()?;
Ok(())
}