From ae3515781923b43cbb792df6a6c4f9208d9cdb87 Mon Sep 17 00:00:00 2001 From: Olivia Zhang Date: Tue, 3 Dec 2024 12:51:06 -0800 Subject: [PATCH] generalize event callsite for qe check logging Summary: It's currently hardcoded to log that it's a verse qe check event, but we want to do qe checke elsewhere as well. The logging macro intentionally requires you to pass a value and not a variable to be logged, so instead, we log the callsite as a field in the data as a workaround. Reviewed By: rjbailey Differential Revision: D66670156 fbshipit-source-id: 1ae7419cdc680f23402f84ad44ce867a98b7363e --- td_util/src/qe.rs | 21 ++++++++++++++++++--- td_util/src/supertd_events.rs | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/td_util/src/qe.rs b/td_util/src/qe.rs index cc0bb06..94f7f87 100644 --- a/td_util/src/qe.rs +++ b/td_util/src/qe.rs @@ -9,6 +9,8 @@ use serde::Serialize; +use crate::supertd_events; + #[derive(Serialize)] #[serde(untagged)] pub enum QEParamValue { @@ -18,7 +20,13 @@ pub enum QEParamValue { } #[cfg(all(fbcode_build, target_os = "linux"))] -pub fn evaluate_qe(unit_id: u64, universe: &str, param: &str, expect: QEParamValue) -> bool { +pub fn evaluate_qe( + unit_id: u64, + universe: &str, + param: &str, + expect: QEParamValue, + step: supertd_events::Step, +) -> bool { use sandcastle_qe2_client::QE2; use tracing::info; @@ -46,18 +54,25 @@ pub fn evaluate_qe(unit_id: u64, universe: &str, param: &str, expect: QEParamVal info!( "Check {param} from QE {universe}, value {value_for_logging} (expected {expect_str}): {ret}" ); - crate::scuba!(event: VERSE_QE_CHECK, data: json!({ + crate::scuba!(event: QE_CHECK, data: json!({ "unit_id": unit_id, "param": param, "universe": universe, "value": value_for_logging, "expect": expect, "result": ret, + "step": step })); ret } #[cfg(not(all(fbcode_build, target_os = "linux")))] -pub fn evaluate_qe(unit_id: u64, universe: &str, param: &str, expect: QEParamValue) -> bool { +pub fn evaluate_qe( + unit_id: u64, + universe: &str, + param: &str, + expect: QEParamValue, + step: supertd_events::Step, +) -> bool { return false; } diff --git a/td_util/src/supertd_events.rs b/td_util/src/supertd_events.rs index a04a154..5ad417e 100644 --- a/td_util/src/supertd_events.rs +++ b/td_util/src/supertd_events.rs @@ -37,7 +37,21 @@ pub enum Event { BUILD_DIRECTIVES_SPECIFIED, RE_METADATA_SUCCESS, GENERATED_TARGETS_COUNT, - VERSE_QE_CHECK, + QE_CHECK, +} + +#[derive(Debug)] +#[allow(non_camel_case_types)] +#[derive(serde::Serialize)] +pub enum Step { + AUDIT, + TARGETS, + BTD, + VERIFIABLE_MATCHER, + RANKER, + VERSE, + SCHEDULER, + RERUN, } /// Initialize the Scuba client for the `supertd_events` dataset.