MCPcopy Create free account
hub / github.com/apache/datafusion / tracing

Function tracing

datafusion-examples/examples/execution_monitoring/tracing.rs:68–95  ·  view source on GitHub ↗

Demonstrates the tracing injection feature for the DataFusion runtime

()

Source from the content-addressed store, hash-verified

66
67/// Demonstrates the tracing injection feature for the DataFusion runtime
68pub 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`.

Callers 1

runMethod · 0.85

Calls 2

run_instrumented_queryFunction · 0.85
set_join_set_tracerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…