Skip to content

Commit 340d252

Browse files
committed
Rename tx_latency to tx_latency_confirmed and add tx_latency_submitted
1 parent 8325657 commit 340d252

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

relayer/src/link/pending.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl<Chain: ChainHandle> PendingTxs<Chain> {
242242
"transactions confirmed",
243243
);
244244

245-
telemetry!(end_process_batch, &self.chain_id(), pending.tracking_id());
245+
telemetry!(tx_confirmed, &self.chain_id(), pending.tracking_id());
246246

247247
// Convert the events to RelaySummary and return them.
248248
let mut summary = RelaySummary::from_events(events);

relayer/src/link/relay_path.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ use crate::link::pending::PendingTxs;
5757
use crate::link::relay_sender::{AsyncReply, SubmitReply};
5858
use crate::link::relay_summary::RelaySummary;
5959
use crate::link::{pending, relay_sender};
60+
use crate::telemetry;
6061
use crate::util::queue::Queue;
6162

6263
const MAX_RETRIES: usize = 5;
@@ -682,8 +683,16 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> RelayPath<ChainA, ChainB> {
682683
let msgs = odata.assemble_msgs(self)?;
683684

684685
match odata.target {
685-
OperationalDataTarget::Source => S::submit(self.src_chain(), msgs),
686-
OperationalDataTarget::Destination => S::submit(self.dst_chain(), msgs),
686+
OperationalDataTarget::Source => {
687+
telemetry!(tx_submitted, &self.src_chain().id(), msgs.tracking_id);
688+
689+
S::submit(self.src_chain(), msgs)
690+
}
691+
OperationalDataTarget::Destination => {
692+
telemetry!(tx_submitted, &self.dst_chain().id(), msgs.tracking_id);
693+
694+
S::submit(self.dst_chain(), msgs)
695+
}
687696
}
688697
}
689698

relayer/src/supervisor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ fn process_batch<Chain: ChainHandle>(
608608
) -> Result<(), Error> {
609609
assert_eq!(src_chain.id(), batch.chain_id);
610610

611-
telemetry!(start_process_batch, batch.tracking_id);
611+
telemetry!(received_event_batch, batch.tracking_id);
612612

613613
let collected = collect_events(config, workers, &src_chain, batch);
614614

telemetry/src/state.rs

+33-6
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ pub struct TelemetryState {
7171
/// The balance in each wallet that Hermes is using, per wallet, denom and chain
7272
wallet_balance: ValueRecorder<u64>,
7373

74+
/// Indicates the latency for all transactions submitted to a specific chain,
75+
/// i.e. the difference between the moment when Hermes received a batch of events
76+
/// until the corresponding transaction(s) were submitted. Milliseconds.
77+
tx_latency_submitted: ValueRecorder<u64>,
78+
7479
/// Indicates the latency for all transactions submitted to a specific chain,
7580
/// i.e. the difference between the moment when Hermes received a batch of events
7681
/// until the corresponding transaction(s) were confirmed. Milliseconds.
77-
tx_latency: ValueRecorder<u64>,
82+
tx_latency_confirmed: ValueRecorder<u64>,
7883

7984
/// Records the time at which we started processing an event batch.
8085
/// Used for computing the `tx_latency` metric.
@@ -216,12 +221,27 @@ impl TelemetryState {
216221
self.wallet_balance.record(amount, labels);
217222
}
218223

219-
pub fn start_process_batch(&self, tracking_id: impl ToString) {
224+
pub fn received_event_batch(&self, tracking_id: impl ToString) {
220225
self.in_flight_events
221226
.insert(tracking_id.to_string(), Instant::now());
222227
}
223228

224-
pub fn end_process_batch(&self, chain_id: &ChainId, tracking_id: impl ToString) {
229+
pub fn tx_submitted(&self, chain_id: &ChainId, tracking_id: impl ToString) {
230+
let tracking_id = tracking_id.to_string();
231+
232+
if let Some(start) = self.in_flight_events.get(&tracking_id) {
233+
let latency = start.elapsed().as_millis() as u64;
234+
235+
let labels = &[
236+
KeyValue::new("chain", chain_id.to_string()),
237+
KeyValue::new("tracking_id", tracking_id),
238+
];
239+
240+
self.tx_latency_submitted.record(latency, labels);
241+
}
242+
}
243+
244+
pub fn tx_confirmed(&self, chain_id: &ChainId, tracking_id: impl ToString) {
225245
let tracking_id = tracking_id.to_string();
226246

227247
if let Some(start) = self.in_flight_events.get(&tracking_id) {
@@ -232,7 +252,7 @@ impl TelemetryState {
232252
KeyValue::new("tracking_id", tracking_id),
233253
];
234254

235-
self.tx_latency.record(latency, labels);
255+
self.tx_latency_confirmed.record(latency, labels);
236256
}
237257
}
238258
}
@@ -307,8 +327,15 @@ impl Default for TelemetryState {
307327
.with_description("The balance in each wallet that Hermes is using, per wallet, denom and chain")
308328
.init(),
309329

310-
tx_latency: meter
311-
.u64_value_recorder("tx_latency")
330+
tx_latency_submitted: meter
331+
.u64_value_recorder("tx_latency_submitted")
332+
.with_description("The latency for all transactions submitted to a specific chain, \
333+
i.e. the difference between the moment when Hermes received a batch of events \
334+
and when it submitted the corresponding transaction(s). Milliseconds.")
335+
.init(),
336+
337+
tx_latency_confirmed: meter
338+
.u64_value_recorder("tx_latency_confirmed")
312339
.with_description("The latency for all transactions submitted to a specific chain, \
313340
i.e. the difference between the moment when Hermes received a batch of events \
314341
until the corresponding transaction(s) were confirmed. Milliseconds.")

0 commit comments

Comments
 (0)