fuchsia_triage/
plugins.rsuse crate::act::{Action, ActionResults, Gauge, Severity};
use crate::metrics::fetch::FileDataFetcher;
use crate::metrics::metric_value::MetricValue;
mod crashes;
mod helpers;
mod memory;
mod routing;
mod sandbox_errors;
pub trait Plugin {
fn name(&self) -> &'static str;
fn display_name(&self) -> &'static str;
fn run(&self, inputs: &FileDataFetcher<'_>) -> ActionResults {
let mut results = ActionResults::new();
results.sort_gauges = false;
let structured_results = self.run_structured(inputs);
for action in structured_results {
match action {
Action::Alert(alert) => match alert.severity {
Severity::Info => results.infos.push(alert.print),
Severity::Warning => results.warnings.push(alert.print),
Severity::Error => results.errors.push(alert.print),
},
Action::Gauge(Gauge { tag: Some(tag), value, .. }) => {
if let Some(MetricValue::String(raw_value)) = value.cached_value.into_inner() {
results.gauges.push(format!("{}: {}", tag, raw_value));
}
}
_ => (),
}
}
results
}
fn run_structured(&self, inputs: &FileDataFetcher<'_>) -> Vec<Action>;
}
pub fn register_plugins() -> Vec<Box<dyn Plugin>> {
vec![
Box::new(crashes::CrashesPlugin {}),
Box::new(sandbox_errors::SandboxErrorsPlugin {}),
Box::new(routing::RoutingErrorsPlugin {}),
Box::new(memory::MemoryPlugin {}),
]
}