|
| 1 | +use opentelemetry::global; |
1 | 2 | use std::{error::Error, thread, time::Duration};
|
2 | 3 | use tracing::{span, trace, warn};
|
3 | 4 | use tracing_attributes::instrument;
|
@@ -26,16 +27,20 @@ fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
|
26 | 27 | .with(opentelemetry)
|
27 | 28 | .try_init()?;
|
28 | 29 |
|
29 |
| - let root = span!(tracing::Level::INFO, "app_start", work_units = 2); |
30 |
| - let _enter = root.enter(); |
| 30 | + { |
| 31 | + let root = span!(tracing::Level::INFO, "app_start", work_units = 2); |
| 32 | + let _enter = root.enter(); |
31 | 33 |
|
32 |
| - let work_result = expensive_work(); |
| 34 | + let work_result = expensive_work(); |
33 | 35 |
|
34 |
| - span!(tracing::Level::INFO, "faster_work") |
35 |
| - .in_scope(|| thread::sleep(Duration::from_millis(10))); |
| 36 | + span!(tracing::Level::INFO, "faster_work") |
| 37 | + .in_scope(|| thread::sleep(Duration::from_millis(10))); |
36 | 38 |
|
37 |
| - warn!("About to exit!"); |
38 |
| - trace!("status: {}", work_result); |
| 39 | + warn!("About to exit!"); |
| 40 | + trace!("status: {}", work_result); |
| 41 | + } |
| 42 | + |
| 43 | + global::shutdown_tracer_provider(); |
39 | 44 |
|
40 | 45 | Ok(())
|
41 | 46 | }
|
0 commit comments