Skip to content

Commit

Permalink
generalize event callsite for qe check logging
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Olivia Zhang authored and facebook-github-bot committed Dec 3, 2024
1 parent 3c3c15d commit ae35157
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
21 changes: 18 additions & 3 deletions td_util/src/qe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

use serde::Serialize;

use crate::supertd_events;

#[derive(Serialize)]
#[serde(untagged)]
pub enum QEParamValue {
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
16 changes: 15 additions & 1 deletion td_util/src/supertd_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ae35157

Please sign in to comment.