Skip to content

Commit e620963

Browse files
authored
chore: add ingress rpc metrics (#105)
* chore: add ingress rpc metrics * bump logs * remove non error log
1 parent 8263c30 commit e620963

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

crates/ingress-rpc/src/metrics.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ pub fn record_histogram(rpc_latency: Duration, rpc: String) {
1818
#[derive(Metrics, Clone)]
1919
#[metrics(scope = "tips_ingress_rpc")]
2020
pub struct Metrics {
21+
#[metric(describe = "Number of valid transactions received")]
22+
pub transactions_received: Counter,
23+
24+
#[metric(describe = "Number of valid bundles parsed")]
25+
pub bundles_parsed: Counter,
26+
27+
#[metric(describe = "Number of bundles simulated")]
28+
pub successful_simulations: Counter,
29+
30+
#[metric(describe = "Number of bundles simulated")]
31+
pub failed_simulations: Counter,
32+
33+
#[metric(describe = "Number of bundles sent to kafka")]
34+
pub sent_to_kafka: Counter,
35+
36+
#[metric(describe = "Number of transactions sent to mempool")]
37+
pub sent_to_mempool: Counter,
38+
2139
#[metric(describe = "Duration of validate_tx")]
2240
pub validate_tx_duration: Histogram,
2341

crates/ingress-rpc/src/service.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ impl<Q: MessageQueue + 'static> IngressApiServer for IngressService<Q> {
204204
let start = Instant::now();
205205
let transaction = self.get_tx(&data).await?;
206206

207+
self.metrics.transactions_received.increment(1);
208+
207209
let send_to_kafka = matches!(
208210
self.tx_submission_method,
209211
TxSubmissionMethod::Kafka | TxSubmissionMethod::MempoolAndKafka
@@ -225,17 +227,23 @@ impl<Q: MessageQueue + 'static> IngressApiServer for IngressService<Q> {
225227
reverting_tx_hashes: vec![transaction.tx_hash()],
226228
..Default::default()
227229
};
230+
228231
let parsed_bundle: ParsedBundle = bundle
229232
.clone()
230233
.try_into()
231234
.map_err(|e: String| EthApiError::InvalidParams(e).into_rpc_err())?;
232235

233236
let bundle_hash = &parsed_bundle.bundle_hash();
234237

238+
self.metrics.bundles_parsed.increment(1);
239+
235240
let meter_bundle_response = self.meter_bundle(&bundle, bundle_hash).await.ok();
236241

237242
if let Some(meter_info) = meter_bundle_response.as_ref() {
243+
self.metrics.successful_simulations.increment(1);
238244
_ = self.builder_tx.send(meter_info.clone());
245+
} else {
246+
self.metrics.failed_simulations.increment(1);
239247
}
240248

241249
let accepted_bundle =
@@ -250,6 +258,7 @@ impl<Q: MessageQueue + 'static> IngressApiServer for IngressService<Q> {
250258
warn!(message = "Failed to publish Queue::enqueue_bundle", bundle_hash = %bundle_hash, error = %e);
251259
}
252260

261+
self.metrics.sent_to_kafka.increment(1);
253262
info!(message="queued singleton bundle", txn_hash=%transaction.tx_hash());
254263
}
255264

@@ -260,6 +269,7 @@ impl<Q: MessageQueue + 'static> IngressApiServer for IngressService<Q> {
260269
.await;
261270
match response {
262271
Ok(_) => {
272+
self.metrics.sent_to_mempool.increment(1);
263273
debug!(message = "sent transaction to the mempool", hash=%transaction.tx_hash());
264274
}
265275
Err(e) => {
@@ -287,7 +297,7 @@ impl<Q: MessageQueue + 'static> IngressApiServer for IngressService<Q> {
287297
});
288298
}
289299

290-
debug!(
300+
info!(
291301
message = "processed transaction",
292302
bundle_hash = %bundle_hash,
293303
transaction_hash = %transaction.tx_hash(),

ui/src/lib/s3.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ async function getObjectContent(key: string): Promise<string | null> {
6060
const body = await response.Body?.transformToString();
6161
return body || null;
6262
} catch (error) {
63-
console.error(`Failed to get S3 object ${key}:`, error);
6463
return null;
6564
}
6665
}

0 commit comments

Comments
 (0)