Skip to content

Commit

Permalink
Added new enum to TrackindId in order to track latency of packets cle…
Browse files Browse the repository at this point in the history
…ared
  • Loading branch information
ljoss17 committed Jul 18, 2022
1 parent 90452e1 commit a75810d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions relayer/src/chain/tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub enum TrackingId {
/// corresponding event batch, eg. when performing actions from
/// the CLI or during packet clearing.
Static(&'static str),
/// Random identifier used to track latency of packet clearing.
ClearedUuid(Uuid),
}

impl TrackingId {
Expand All @@ -26,6 +28,10 @@ impl TrackingId {
pub fn new_static(s: &'static str) -> Self {
Self::Static(s)
}

pub fn new_cleared_uuid() -> Self {
Self::ClearedUuid(Uuid::new_v4())
}
}

impl fmt::Display for TrackingId {
Expand All @@ -37,6 +43,13 @@ impl fmt::Display for TrackingId {
s.fmt(f)
}
TrackingId::Static(s) => s.fmt(f),
TrackingId::ClearedUuid(u) => {
let mut uuid = "cleared/".to_owned();
let mut s = u.to_string();
s.truncate(8);
uuid.push_str(&s);
uuid.fmt(f)
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion relayer/src/link/relay_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> RelayPath<ChainA, ChainB> {
}

fn relay_pending_packets(&self, height: Option<Height>) -> Result<(), LinkError> {
let tracking_id = TrackingId::new_static("relay pending packets");
let tracking_id = TrackingId::new_cleared_uuid();
telemetry!(received_event_batch, tracking_id);

for i in 1..=MAX_RETRIES {
let cleared = self
Expand Down

0 comments on commit a75810d

Please sign in to comment.