Watch
0
0
Fork
You've already forked hyperhive
0

notify router: log each delivered forge event and each sink outcome

This commit is contained in:
atlas 2026-10-25 21:49:51 +01:00
commit 7a964c9c5c

View file

@ -80,6 +80,43 @@ impl Cause {
}
}
/// Log one routed delivery: at info when `flows` flows produced a todo or a
/// review request, at debug when none did, so deliveries nothing wants do not
/// flood the log. It names the sender and never the body.
pub fn delivery(
event_type: &str,
delivery: &crate::event::Delivery,
delivery_id: Option<&str>,
flows: usize,
) {
let (repo, number, sender, action) = (
&delivery.repo,
delivery.number,
&delivery.sender,
&delivery.action,
);
let delivery_id = delivery_id.unwrap_or("none");
if flows == 0 {
tracing::debug!(event_type, %action, %repo, number, %sender, delivery_id, flows, "notify router: forge event matched no flow");
} else {
tracing::info!(event_type, %action, %repo, number, %sender, delivery_id, flows, "notify router: forge event routed");
}
}
/// Log what one sink of `flow` did for `target` on the issue or PR `cause` names: info when it went through,
/// warn with the error when it did not.
pub fn sink(cause: &Cause, flow: &str, kind: Kind, target: &str, result: &Result<String, String>) {
let (repo, number) = (&cause.repo, cause.number);
match result {
Ok(outcome) => {
tracing::info!(%flow, %repo, number, ?kind, %target, %outcome, "notify router: sink ran");
}
Err(error) => {
tracing::warn!(%flow, %repo, number, ?kind, %target, %error, "notify router: sink failed");
}
}
}
/// Append `row`; a failure, or an append that takes longer than
/// `APPEND_WITHIN`, is logged and dropped. It is awaited in place, so rows
/// keep the order of the deliveries.