MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / collect

Function collect

src/runtime_telemetry.rs:83–96  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

81/// rather than failing the whole snapshot, because the value of this
82/// tool is recording *what's available* during a spike.
83pub 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.

Callers 1

handle_status_commandFunction · 0.70

Calls 2

sample_processFunction · 0.85
sample_databaseFunction · 0.85

Tested by

no test coverage detected