use std::sync::Arc;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum RunnerType {
Subprocess,
Container,
Wasm,
}
impl RunnerType {
#[inline]
pub fn as_label(self) -> &'static str {
match self {
Self::Subprocess => "subprocess",
Self::Container => "container",
Self::Wasm => "wasm",
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TaskOutcome {
Success,
Failure,
Canceled,
Timeout,
}
impl TaskOutcome {
#[inline]
pub fn as_label(&self) -> &'static str {
match self {
TaskOutcome::Success => "success",
TaskOutcome::Failure => "failure",
TaskOutcome::Canceled => "canceled",
TaskOutcome::Timeout => "timeout",
}
}
}
pub trait MetricsBackend: Send + Sync + 'static {
fn record_task_started(&self, runner_type: RunnerType);
fn record_task_completed(
&self,
runner_type: RunnerType,
outcome: TaskOutcome,
duration_ms: u64,
);
fn record_runner_error(&self, runner_type: RunnerType, error_kind: &str);
}
pub type MetricsHandle = Arc<dyn MetricsBackend>;