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

fix: improve svm landing time metric #373

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auction-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "auction-server"
version = "0.17.0"
version = "0.17.1"
edition = "2021"
license-file = "license.txt"

Expand Down
13 changes: 7 additions & 6 deletions auction-server/src/auction/service/auction_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use {
self,
service::get_live_opportunities::GetLiveOpportunitiesInput,
},
server::TRANSACTION_LANDING_TIME_SVM_METRIC,
},
anyhow::Result,
axum::async_trait,
Expand Down Expand Up @@ -678,8 +679,7 @@ impl Service<Svm> {
}

#[tracing::instrument(skip_all, fields(bid_id, total_tries, tx_hash))]
async fn blocking_send_transaction(&self, bid: entities::Bid<Svm>) {
let start = Instant::now();
async fn blocking_send_transaction(&self, bid: entities::Bid<Svm>, start: Instant) {
let mut result_label = METRIC_LABEL_EXPIRED;
let signature = bid.chain_data.transaction.signatures[0];
tracing::Span::current().record("bid_id", bid.id.to_string());
Expand Down Expand Up @@ -726,7 +726,7 @@ impl Service<Svm> {
// but this is rare as we retry for 60 seconds and blockhash expires after 60 seconds
("result", result_label.to_string()),
];
metrics::histogram!("transaction_landing_time_seconds_svm", &labels)
metrics::histogram!(TRANSACTION_LANDING_TIME_SVM_METRIC, &labels)
.record(start.elapsed().as_secs_f64());

tracing::Span::current().record("total_tries", retry_count + 1);
Expand All @@ -738,18 +738,19 @@ impl Service<Svm> {
bid: &entities::Bid<Svm>,
) -> solana_client::client_error::Result<Signature> {
tracing::Span::current().record("bid_id", bid.id.to_string());
let start = Instant::now();
let tx = &bid.chain_data.transaction;
self.send_transaction_to_network(&bid.chain_data.transaction)
.await?;
self.send_transaction_to_network(tx).await?;
self.config
.chain_config
.simulator
.add_pending_transaction(tx)
.await;

self.task_tracker.spawn({
let (service, bid) = (self.clone(), bid.clone());
async move {
service.blocking_send_transaction(bid).await;
service.blocking_send_transaction(bid, start).await;
}
});
Ok(tx.signatures[0])
Expand Down
12 changes: 12 additions & 0 deletions auction-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,20 @@ async fn fetch_access_tokens(db: &PgPool) -> HashMap<models::AccessTokenToken, m
.collect()
}

pub const TRANSACTION_LANDING_TIME_SVM_METRIC: &str = "transaction_landing_time_seconds_svm";
const TRANSACTION_LANDING_TIME_SVM_BUCKETS: &[f64; 14] = &[
0.1, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.75, 5.0, 10.0,
];

pub fn setup_metrics_recorder() -> Result<PrometheusHandle> {
PrometheusBuilder::new()
.set_buckets_for_metric(
axum_prometheus::metrics_exporter_prometheus::Matcher::Full(
TRANSACTION_LANDING_TIME_SVM_METRIC.to_string(),
),
TRANSACTION_LANDING_TIME_SVM_BUCKETS,
)
.unwrap()
.set_buckets(SECONDS_DURATION_BUCKETS)
.unwrap()
.install_recorder()
Expand Down
Loading