mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-26 15:32:30 +00:00
agent: flush root span before process finish
Variables in rust will be dropped at the end of the function. In function real_main the trace will be shut down by `tracer::end_tracing()`, but at this time the root span is in an active state, so this root span will not be sent to the trace collector. This can be fixed by dropping the root span manually. Fixes: #2812 Signed-off-by: bin <bin@hyper.sh>
This commit is contained in:
parent
0300e91cd0
commit
2d7b65e8eb
@ -200,12 +200,12 @@ async fn real_main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
|||||||
let _ = tracer::setup_tracing(NAME, &logger, &config)?;
|
let _ = tracer::setup_tracing(NAME, &logger, &config)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let root = span!(tracing::Level::TRACE, "root-span", work_units = 2);
|
let root_span = span!(tracing::Level::TRACE, "root-span");
|
||||||
|
|
||||||
// XXX: Start the root trace transaction.
|
// XXX: Start the root trace transaction.
|
||||||
//
|
//
|
||||||
// XXX: Note that *ALL* spans needs to start after this point!!
|
// XXX: Note that *ALL* spans needs to start after this point!!
|
||||||
let _enter = root.enter();
|
let span_guard = root_span.enter();
|
||||||
|
|
||||||
// Start the sandbox and wait for its ttRPC server to end
|
// Start the sandbox and wait for its ttRPC server to end
|
||||||
start_sandbox(&logger, &config, init_mode, &mut tasks, shutdown_rx.clone()).await?;
|
start_sandbox(&logger, &config, init_mode, &mut tasks, shutdown_rx.clone()).await?;
|
||||||
@ -235,6 +235,10 @@ async fn real_main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// force flushing spans
|
||||||
|
drop(span_guard);
|
||||||
|
drop(root_span);
|
||||||
|
|
||||||
if config.tracing != tracer::TraceType::Disabled {
|
if config.tracing != tracer::TraceType::Disabled {
|
||||||
tracer::end_tracing();
|
tracer::end_tracing();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user