Demonstrates the tracing injection feature for the DataFusion runtime
()
| 66 | |
| 67 | /// Demonstrates the tracing injection feature for the DataFusion runtime |
| 68 | pub async fn tracing() -> Result<()> { |
| 69 | // Initialize tracing subscriber with thread info. |
| 70 | tracing_subscriber::fmt() |
| 71 | .with_thread_ids(true) |
| 72 | .with_thread_names(true) |
| 73 | .with_max_level(Level::DEBUG) |
| 74 | .init(); |
| 75 | |
| 76 | // Run query WITHOUT tracer injection. |
| 77 | info!("***** RUNNING WITHOUT INJECTED TRACER *****"); |
| 78 | run_instrumented_query().await?; |
| 79 | info!( |
| 80 | "***** WITHOUT tracer: `tokio-runtime-worker` tasks did NOT inherit the `run_instrumented_query` span *****" |
| 81 | ); |
| 82 | |
| 83 | // Inject custom tracer so tasks run in the current span. |
| 84 | info!("Injecting custom tracer..."); |
| 85 | set_join_set_tracer(&SpanTracer).expect("Failed to set tracer"); |
| 86 | |
| 87 | // Run query WITH tracer injection. |
| 88 | info!("***** RUNNING WITH INJECTED TRACER *****"); |
| 89 | run_instrumented_query().await?; |
| 90 | info!( |
| 91 | "***** WITH tracer: `tokio-runtime-worker` tasks DID inherit the `run_instrumented_query` span *****" |
| 92 | ); |
| 93 | |
| 94 | Ok(()) |
| 95 | } |
| 96 | |
| 97 | /// A simple tracer that ensures any spawned task or blocking closure |
| 98 | /// inherits the current span via `in_current_span`. |
no test coverage detected
searching dependent graphs…