Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run loop additional metrics #2888

Merged
merged 14 commits into from
Aug 16, 2024
13 changes: 13 additions & 0 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl RunLoop {
}

async fn single_run(&self, auction_id: domain::auction::Id, auction: &domain::Auction) {
let _timer = Metrics::get().single_run_time.start_timer();
tracing::info!(?auction_id, "solving");

let auction = self.remove_in_flight_orders(auction.clone()).await;
Expand Down Expand Up @@ -145,6 +146,7 @@ impl RunLoop {

// TODO: Keep going with other solutions until some deadline.
if let Some(Participant { driver, solution }) = solutions.last() {
let timer = Metrics::get().solutions_processing_time.start_timer();
squadgazzz marked this conversation as resolved.
Show resolved Hide resolved
tracing::info!(driver = %driver.name, solution = %solution.id(), "winner");

let revealed = match self.reveal(driver, auction_id, solution.id()).await {
Expand Down Expand Up @@ -305,6 +307,7 @@ impl RunLoop {
Metrics::fee_policies_store_error();
tracing::warn!(?err, "failed to save fee policies");
}
timer.observe_duration();

tracing::info!(driver = %driver.name, "settling");
let submission_start = Instant::now();
Expand Down Expand Up @@ -352,6 +355,7 @@ impl RunLoop {
self.persistence
.store_order_events(order_uids, OrderEventLabel::Ready);

let _timer = Metrics::get().solvers_response_time.start_timer();
squadgazzz marked this conversation as resolved.
Show resolved Hide resolved
let start = Instant::now();
futures::future::join_all(self.drivers.iter().map(|driver| async move {
let result = self.solve(driver, request).await;
Expand Down Expand Up @@ -650,6 +654,15 @@ struct Metrics {
/// Tracks the number of database errors.
#[metric(labels("error_type"))]
db_metric_error: prometheus::IntCounterVec,

/// Tracks the time taken for all the solvers to respond.
solvers_response_time: prometheus::Histogram,

/// Tracks the time taken for ranking solutions.
solutions_processing_time: prometheus::Histogram,

/// Total time spent in a single run of the run loop.
single_run_time: prometheus::Histogram,
}

impl Metrics {
Expand Down
6 changes: 5 additions & 1 deletion crates/autopilot/src/solvable_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use {
},
number::conversions::u256_to_big_decimal,
primitive_types::{H160, H256, U256},
prometheus::{IntCounter, IntCounterVec, IntGauge, IntGaugeVec},
prometheus::{Histogram, IntCounter, IntCounterVec, IntGauge, IntGaugeVec},
shared::{
account_balances::{BalanceFetching, Query},
bad_token::BadTokenDetecting,
Expand All @@ -43,6 +43,9 @@ pub struct Metrics {
#[metric(labels("result"))]
auction_update: IntCounterVec,

/// Time taken to update the solvable orders cache.
auction_update_time: Histogram,

/// Auction creations.
auction_creations: IntCounter,

Expand Down Expand Up @@ -144,6 +147,7 @@ impl SolvableOrdersCache {
/// the case in unit tests, then concurrent calls might overwrite each
/// other's results.
async fn update(&self, block: u64) -> Result<()> {
let _timer = self.metrics.auction_update_time.start_timer();
let min_valid_to = now_in_epoch_seconds() + self.min_order_validity_period.as_secs() as u32;
let db_solvable_orders = self.persistence.solvable_orders(min_valid_to).await?;

Expand Down
Loading