Skip to content

Commit 553ee14

Browse files
committed
Add more labels to tx_latency_* metrics
1 parent 2d452cd commit 553ee14

File tree

3 files changed

+74
-15
lines changed

3 files changed

+74
-15
lines changed

relayer/src/link/pending.rs

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

245-
telemetry!(tx_confirmed, &self.chain_id(), pending.tracking_id());
245+
telemetry!(
246+
tx_confirmed,
247+
pending.tracking_id(),
248+
&self.chain.id(),
249+
&self.channel_id,
250+
&self.port_id,
251+
&self.counterparty_chain_id
252+
);
246253

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

relayer/src/link/relay_path.rs

+41-10
Original file line numberDiff line numberDiff line change
@@ -682,17 +682,21 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> RelayPath<ChainA, ChainB> {
682682

683683
let msgs = odata.assemble_msgs(self)?;
684684

685-
match odata.target {
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);
685+
telemetry!({
686+
let (chain, counterparty, channel_id, port_id) = self.target_info(odata.target);
687+
688+
ibc_telemetry::global().tx_submitted(
689+
msgs.tracking_id,
690+
&chain,
691+
channel_id,
692+
port_id,
693+
&counterparty,
694+
);
695+
});
693696

694-
S::submit(self.dst_chain(), msgs)
695-
}
697+
match odata.target {
698+
OperationalDataTarget::Source => S::submit(self.src_chain(), msgs),
699+
OperationalDataTarget::Destination => S::submit(self.dst_chain(), msgs),
696700
}
697701
}
698702

@@ -1680,4 +1684,31 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> RelayPath<ChainA, ChainB> {
16801684
self.src_chain().clone(),
16811685
)
16821686
}
1687+
1688+
// we need fully qualified ChainId to avoid unneeded imports warnings
1689+
#[cfg(feature = "telemetry")]
1690+
fn target_info(
1691+
&self,
1692+
target: OperationalDataTarget,
1693+
) -> (
1694+
ibc::core::ics24_host::identifier::ChainId, // source chain
1695+
ibc::core::ics24_host::identifier::ChainId, // destination chain
1696+
&ChannelId,
1697+
&PortId,
1698+
) {
1699+
match target {
1700+
OperationalDataTarget::Source => (
1701+
self.src_chain().id(),
1702+
self.dst_chain().id(),
1703+
&self.src_channel_id,
1704+
&self.src_port_id,
1705+
),
1706+
OperationalDataTarget::Destination => (
1707+
self.dst_chain().id(),
1708+
self.src_chain().id(),
1709+
&self.dst_channel_id,
1710+
&self.dst_port_id,
1711+
),
1712+
}
1713+
}
16831714
}

telemetry/src/state.rs

+25-4
Original file line numberDiff line numberDiff line change
@@ -226,30 +226,51 @@ impl TelemetryState {
226226
.insert(tracking_id.to_string(), Instant::now());
227227
}
228228

229-
pub fn tx_submitted(&self, chain_id: &ChainId, tracking_id: impl ToString) {
229+
pub fn tx_submitted(
230+
&self,
231+
232+
tracking_id: impl ToString,
233+
chain_id: &ChainId,
234+
channel_id: &ChannelId,
235+
port_id: &PortId,
236+
counterparty_chain_id: &ChainId,
237+
) {
230238
let tracking_id = tracking_id.to_string();
231239

232240
if let Some(start) = self.in_flight_events.get(&tracking_id) {
233241
let latency = start.elapsed().as_millis() as u64;
234242

235243
let labels = &[
236-
KeyValue::new("chain", chain_id.to_string()),
237244
KeyValue::new("tracking_id", tracking_id),
245+
KeyValue::new("chain", chain_id.to_string()),
246+
KeyValue::new("counterparty", counterparty_chain_id.to_string()),
247+
KeyValue::new("channel", channel_id.to_string()),
248+
KeyValue::new("port", port_id.to_string()),
238249
];
239250

240251
self.tx_latency_submitted.record(latency, labels);
241252
}
242253
}
243254

244-
pub fn tx_confirmed(&self, chain_id: &ChainId, tracking_id: impl ToString) {
255+
pub fn tx_confirmed(
256+
&self,
257+
tracking_id: impl ToString,
258+
chain_id: &ChainId,
259+
channel_id: &ChannelId,
260+
port_id: &PortId,
261+
counterparty_chain_id: &ChainId,
262+
) {
245263
let tracking_id = tracking_id.to_string();
246264

247265
if let Some(start) = self.in_flight_events.get(&tracking_id) {
248266
let latency = start.elapsed().as_millis() as u64;
249267

250268
let labels = &[
251-
KeyValue::new("chain", chain_id.to_string()),
252269
KeyValue::new("tracking_id", tracking_id),
270+
KeyValue::new("chain", chain_id.to_string()),
271+
KeyValue::new("counterparty", counterparty_chain_id.to_string()),
272+
KeyValue::new("channel", channel_id.to_string()),
273+
KeyValue::new("port", port_id.to_string()),
253274
];
254275

255276
self.tx_latency_confirmed.record(latency, labels);

0 commit comments

Comments
 (0)