Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ tempfile = "3.27"
tokio = { version = "1.53", features = ["full"] }
tokio-stream = "0.1"
tokio-vsock = "0.7"
# The blocking AF_VSOCK stream the guest daemon's telemetry sender writes
# the host over (`minimald::telemetry_forward`), tokio-vsock's own base.
vsock = "0.5"
tokio-util = "0.7"
toml = "1.1"
toml_edit = "0.25"
Expand Down
18 changes: 17 additions & 1 deletion crates/minimal/src/diag/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,23 @@ pub async fn spool(
) -> Result<(), anyhow::Error> {
let dir = spool_dir(paths, std::env::var_os("MINIMAL_OTEL_SPOOL_DIR"));
let headers = diagnostics::redact::exporter_header_values(|n| std::env::var(n).ok());
spool_in(w, &dir, tail_bytes, &headers).await
spool_in(w, &dir, tail_bytes, &headers).await?;
// The VMs' guest spools, `<dir>/guest/<vm>/`, each bounded on its own
// (`mlog::otel::spool_guest_line`): collected beside the host's. `guest`
// itself is taken only as a real directory, the no-follow discipline
// `diagnostics::spool::collect` applies to each directory it is handed.
let guest = dir.join("guest");
let guest_is_dir = tokio::fs::symlink_metadata(&guest)
.await
.is_ok_and(|m| m.is_dir());
if guest_is_dir && let Ok(mut vms) = tokio::fs::read_dir(&guest).await {
while let Ok(Some(vm)) = vms.next_entry().await {
if vm.file_type().await.is_ok_and(|t| t.is_dir()) {
spool_in(w, &vm.path(), tail_bytes, &headers).await?;
}
}
}
Ok(())
}

/// The spool directory `min bug` reads: `override_dir`, the value of
Expand Down
1 change: 1 addition & 0 deletions crates/minimald/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ tracing-opentelemetry.workspace = true
# The guest (initramfs pid-1) boot path is Linux-only.
[target.'cfg(target_os = "linux")'.dependencies]
tokio-vsock.workspace = true
vsock.workspace = true

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/minimald/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub mod session_sop;
mod sessions;
mod sftp;
mod store;
#[cfg(target_os = "linux")]
pub mod telemetry_forward;
#[cfg(any(test, feature = "test-support"))]
pub mod test_harness;
pub mod traced;
Expand Down
17 changes: 17 additions & 0 deletions crates/minimald/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,16 @@ fn main() -> Result<(), MainError> {
// `GetRecord`). Bounded, so a stuck task cannot hold the exit.
runtime.shutdown_timeout(std::time::Duration::from_secs(2));
mlog::otel::shutdown(std::time::Duration::from_secs(5));
// The guest's forwarded records (TEL-034): give the sender a moment to
// write the spans that just ended to the host before the VM goes down.
#[cfg(target_os = "linux")]
if is_minimal_microvm()
&& !minimald::telemetry_forward::drain(std::time::Duration::from_millis(500))
{
tracing::warn!(
"telemetry forward: records still queued at shutdown; the host spool keeps what arrived"
);
}
// Only now, with the flush done (or given up on), take the egress down.
egress.tear_down();

Expand Down Expand Up @@ -705,6 +715,13 @@ async fn async_main(egress: &mut GuestEgress) -> Result<(), MainError> {
LogMode::Console
};
let logger = DaemonLogger::install(log_mode)?;
// The guest's telemetry sender (TEL-034): started once telemetry is
// initialised (in the logger), a no-op unless the boot line named a
// forward destination.
#[cfg(target_os = "linux")]
if is_minimal_microvm() {
minimald::telemetry_forward::start();
}

let listen_args = cli.listen_args().unwrap();

Expand Down
Loading
Loading