Skip to content

Commit

Permalink
Add debug log to FailOnMismatch tee behaviour (#1323)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Kent <rubickent@gmail.com>
  • Loading branch information
conorbros and rukai authored Sep 5, 2023
1 parent 2f10d1c commit 66e5c1e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions shotover/src/transforms/tee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use anyhow::Result;
use async_trait::async_trait;
use metrics::{register_counter, Counter};
use serde::Deserialize;
use tracing::trace;
use tracing::{debug, trace};

pub struct TeeBuilder {
pub tx: TransformChainBuilder,
Expand Down Expand Up @@ -170,10 +170,22 @@ impl Transform for Tee {
.process_request(requests_wrapper.clone(), self.timeout_micros),
requests_wrapper.call_next_transform()
);
let tee_response = tee_result?;
let mut tee_response = tee_result?;
let mut chain_response = chain_result?;

if !chain_response.eq(&tee_response) {
debug!(
"Tee mismatch: \nchain response: {:?} \ntee response: {:?}",
chain_response
.iter_mut()
.map(|m| m.to_high_level_string())
.collect::<Vec<_>>(),
tee_response
.iter_mut()
.map(|m| m.to_high_level_string())
.collect::<Vec<_>>()
);

for message in &mut chain_response {
*message = message.to_error_response(
"ERR The responses from the Tee subchain and down-chain did not match and behavior is set to fail on mismatch".into())?;
Expand Down

0 comments on commit 66e5c1e

Please sign in to comment.