From d96577d441e774eb22c6c1d78eaf84f9fadf39e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 13 Feb 2024 13:51:51 +0100 Subject: [PATCH] WIP --- tracing-trace/src/bin/filter-trace.rs | 40 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/tracing-trace/src/bin/filter-trace.rs b/tracing-trace/src/bin/filter-trace.rs index 8e3de0df3..b71915a85 100644 --- a/tracing-trace/src/bin/filter-trace.rs +++ b/tracing-trace/src/bin/filter-trace.rs @@ -6,7 +6,7 @@ use std::mem; use anyhow::Context; use byte_unit::Byte; use clap::Parser; -use tracing_trace::entry::Entry; +use tracing_trace::entry::{Entry, NewSpan}; /// A program that filters trace logs to only keeps /// the logs related to memory usage above the given threshold. @@ -32,22 +32,34 @@ fn main() -> anyhow::Result<()> { let mut output = io::BufWriter::new(io::stdout()); for result in tracing_trace::TraceReader::new(input) { let entry = result?; - if matches!(entry, Entry::NewCallsite(_) | Entry::NewThread(_)) { - write_to_output(&mut output, &entry)?; - } else if entry.memory().map_or(true, |m| m.resident < memory_threshold.as_u64()) { - if mem::replace(&mut currently_in_threshold, false) { - for entry in context.drain() { - write_to_output(&mut output, &entry)?; - } - } - context.push(entry); - } else { - currently_in_threshold = true; - for entry in context.drain() { + + match entry { + Entry::NewCallsite(_) | Entry::NewThread(_) => { write_to_output(&mut output, &entry)?; } - write_to_output(&mut output, &entry)?; + Entry::NewSpan(NewSpan { id, call_id, parent_id, thread_id }) => todo!(), + Entry::SpanEnter(_) => todo!(), + Entry::SpanExit(_) => todo!(), + Entry::SpanClose(_) => todo!(), + Entry::Event(_) => todo!(), } + + // if matches!(entry, Entry::NewCallsite(_) | Entry::NewThread(_)) { + // write_to_output(&mut output, &entry)?; + // } else if entry.memory().map_or(true, |m| m.resident < memory_threshold.as_u64()) { + // if mem::replace(&mut currently_in_threshold, false) { + // for entry in context.drain() { + // write_to_output(&mut output, &entry)?; + // } + // } + // context.push(entry); + // } else { + // currently_in_threshold = true; + // for entry in context.drain() { + // write_to_output(&mut output, &entry)?; + // } + // write_to_output(&mut output, &entry)?; + // } } for entry in context.drain() {