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

Function sample_database

src/runtime_telemetry.rs:216–236  ·  view source on GitHub ↗
(cg: &crate::tracedecay::TraceDecay)

Source from the content-addressed store, hash-verified

214// ---------------------------------------------------------------------------
215
216async fn sample_database(cg: &crate::tracedecay::TraceDecay) -> Result<DatabaseSnapshot> {
217 let project_root = cg.project_root().to_path_buf();
218 let db_path = cg.db_path().clone();
219 let db_size_bytes = file_size(&db_path);
220 let wal_size_bytes = file_size(&with_suffix(&db_path, "-wal"));
221 let shm_size_bytes = file_size(&with_suffix(&db_path, "-shm"));
222 let journal_mode = read_journal_mode(cg).await.ok();
223 let source_total_bytes = read_source_total_bytes(cg).await.unwrap_or(0);
224 let (node_count, edge_count) = read_graph_counts(cg).await.unwrap_or((0, 0));
225 Ok(DatabaseSnapshot {
226 project_root,
227 db_path,
228 db_size_bytes,
229 wal_size_bytes,
230 shm_size_bytes,
231 journal_mode,
232 source_total_bytes,
233 node_count,
234 edge_count,
235 })
236}
237
238fn file_size(path: &Path) -> u64 {
239 std::fs::metadata(path).map_or(0, |m| m.len())

Callers 1

collectFunction · 0.85

Calls 7

with_suffixFunction · 0.85
read_journal_modeFunction · 0.85
read_source_total_bytesFunction · 0.85
read_graph_countsFunction · 0.85
file_sizeFunction · 0.70
project_rootMethod · 0.45
db_pathMethod · 0.45

Tested by

no test coverage detected