Skip to content

Commit b7b251e

Browse files
authoredJan 21, 2025··
Count total requests sent to dex API (#102)
### Context The oneinch solver on arbitrum currently causes a lot of noisy alerts which aren't really actionable. When looking at the alert it appears as if ~40% of the request to the 1inch API return unexpected errors. However, after closer investigation it seems like this alert actually counts how many of the errors are unexpected errors. Specifically for the arbitrum 1inch case <1% of all requests result in an unexpected error but 40% of all errors are unexpected. Since 99% of the requests actually result in reasonable responses (albeit not good enough to satisfy the order's limit price) the 1inch solver should actually be considered healthy. ### Solution The error handling logic is surprisingly messy: Errors are grouped in weird ways, handled in multiple places and used in conjunction with `Option`. To resolve the noisy alert ASAP using a minimal patch without having to rethink all the error handling logic I decided to just introduce another metric which simply counts all requests sent to the API. After this gets merged the alert should be updated to alert based on the ratio `unexpected_errors / total_requests` instead of `unexpected_errors / total_errors`
1 parent b76dcc2 commit b7b251e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

‎src/domain/solver/dex/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ impl Dex {
155155
self.dex
156156
.swap(dex_order, &slippage, tokens)
157157
.await
158+
.inspect(|_| infra::metrics::request_sent())
158159
.map_err(dex_err_handler)
159160
};
160161
self.rate_limiter

‎src/infra/metrics.rs

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ struct Metrics {
1212
#[metric(buckets(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15))]
1313
remaining_time: prometheus::Histogram,
1414

15+
/// Total number of requests that got sent to the DEX API.
16+
solve_requests: prometheus::IntCounter,
17+
1518
/// Errors that occurred during solving.
1619
#[metric(labels("reason"))]
1720
solve_errors: prometheus::IntCounterVec,
@@ -46,6 +49,10 @@ pub fn solve_error(reason: &str) {
4649
get().solve_errors.with_label_values(&[reason]).inc();
4750
}
4851

52+
pub fn request_sent() {
53+
get().solve_requests.inc();
54+
}
55+
4956
/// Get the metrics instance.
5057
fn get() -> &'static Metrics {
5158
Metrics::instance(observe::metrics::get_storage_registry())

0 commit comments

Comments
 (0)
Please sign in to comment.