Capture a runtime snapshot for the given project. Two responsibilities: (a) sample our own process via `sysinfo`, (b) `stat` the `SQLite` files and ask the connection for its journal mode. Both are best-effort — failures degrade to zeroes / `None` rather than failing the whole snapshot, because the value of this tool is recording *what's available* during a spike.
(cg: &crate::tracedecay::TraceDecay)
| 81 | /// rather than failing the whole snapshot, because the value of this |
| 82 | /// tool is recording *what's available* during a spike. |
| 83 | pub async fn collect(cg: &crate::tracedecay::TraceDecay) -> Result<RuntimeSnapshot> { |
| 84 | let process = sample_process(); |
| 85 | let database = sample_database(cg).await?; |
| 86 | let captured_at = std::time::SystemTime::now() |
| 87 | .duration_since(std::time::UNIX_EPOCH) |
| 88 | .map_or(0, |d| d.as_secs()); |
| 89 | Ok(RuntimeSnapshot { |
| 90 | captured_at, |
| 91 | tracedecay_version: env!("CARGO_PKG_VERSION"), |
| 92 | host_os: std::env::consts::OS, |
| 93 | process, |
| 94 | database, |
| 95 | }) |
| 96 | } |
| 97 | |
| 98 | /// Render a `RuntimeSnapshot` as the JSON wire shape used by both the |
| 99 | /// CLI (`--json` flag) and the MCP tool result. |
no test coverage detected