Skip to content

Commit 3a32fd7

Browse files
devin-ai-integration[bot]Jayant Krishnamurthy
andcommitted
feat: implement request duration tracking in process_event_with_backoff
Co-Authored-By: Jayant Krishnamurthy <[email protected]>
1 parent 570510d commit 3a32fd7

File tree

3 files changed

+42
-27
lines changed

3 files changed

+42
-27
lines changed

apps/fortuna/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
[package]
2-
name = "fortuna"
3-
version = "6.6.0"
2+
name = "fortuna"
3+
version = "6.7.0"
44
edition = "2021"
55

66
[dependencies]
7-
anyhow = "1.0.75"
8-
axum = { version = "0.6.20", features = ["json", "ws", "macros"] }
9-
axum-macros = { version = "0.3.8" }
10-
base64 = { version = "0.21.0" }
7+
anyhow = "1.0.75"
8+
axum = { version = "0.6.20", features = ["json", "ws", "macros"] }
9+
axum-macros = { version = "0.3.8" }
10+
base64 = { version = "0.21.0" }
1111
bincode = "1.3.3"
12-
byteorder = "1.5.0"
13-
clap = { version = "4.4.6", features = ["derive", "cargo", "env"] }
14-
ethabi = "18.0.0"
15-
ethers = { version = "2.0.14", features = ["ws"] }
16-
futures = { version = "0.3.28" }
12+
byteorder = "1.5.0"
13+
clap = { version = "4.4.6", features = ["derive", "cargo", "env"] }
14+
ethabi = "18.0.0"
15+
ethers = { version = "2.0.14", features = ["ws"] }
16+
futures = { version = "0.3.28" }
1717
hex = "0.4.3"
18-
prometheus-client = { version = "0.21.2" }
18+
prometheus-client = { version = "0.21.2" }
1919
pythnet-sdk = { path = "../../pythnet/pythnet_sdk", features = ["strum"] }
20-
rand = "0.8.5"
21-
reqwest = { version = "0.11.22", features = ["json", "blocking"] }
22-
serde = { version = "1.0.188", features = ["derive"] }
23-
serde_qs = { version = "0.12.0", features = ["axum"] }
24-
serde_json = "1.0.107"
20+
rand = "0.8.5"
21+
reqwest = { version = "0.11.22", features = ["json", "blocking"] }
22+
serde = { version = "1.0.188", features = ["derive"] }
23+
serde_qs = { version = "0.12.0", features = ["axum"] }
24+
serde_json = "1.0.107"
2525
serde_with = { version = "3.4.0", features = ["hex", "base64"] }
2626
serde_yaml = "0.9.25"
27-
sha3 = "0.10.8"
28-
tokio = { version = "1.33.0", features = ["full"] }
29-
tower-http = { version = "0.4.0", features = ["cors"] }
30-
tracing = { version = "0.1.37", features = ["log"] }
27+
sha3 = "0.10.8"
28+
tokio = { version = "1.33.0", features = ["full"] }
29+
tower-http = { version = "0.4.0", features = ["cors"] }
30+
tracing = { version = "0.1.37", features = ["log"] }
3131
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
32-
utoipa = { version = "3.4.0", features = ["axum_extras"] }
33-
utoipa-swagger-ui = { version = "3.1.4", features = ["axum"] }
32+
utoipa = { version = "3.4.0", features = ["axum_extras"] }
33+
utoipa-swagger-ui = { version = "3.1.4", features = ["axum"] }
3434
once_cell = "1.18.0"
3535
lazy_static = "1.4.0"
3636
url = "2.5.0"
37-
chrono = { version = "0.4.38", features = ["clock", "std"] , default-features = false}
37+
chrono = { version = "0.4.38", features = [
38+
"clock",
39+
"std",
40+
], default-features = false }
3841
backoff = { version = "0.4.0", features = ["futures", "tokio"] }
3942
thiserror = "1.0.61"
4043
futures-locks = "0.7.1"

apps/fortuna/src/keeper.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ impl Default for KeeperMetrics {
9292
request_duration_ms: Family::new_with_constructor(|| {
9393
Histogram::new(
9494
vec![
95-
1.0, 5.0, 10.0, 50.0, 100.0, 500.0, 1000.0, 5000.0, 10000.0, 30000.0,
96-
60000.0,
95+
1000.0, 2500.0, 5000.0, 7500.0, 10000.0, 20000.0, 30000.0, 40000.0,
96+
50000.0, 60000.0,
9797
]
9898
.into_iter(),
9999
)
@@ -374,6 +374,8 @@ pub async fn process_event_with_backoff(
374374
gas_limit: U256,
375375
metrics: Arc<KeeperMetrics>,
376376
) {
377+
let start_time = std::time::Instant::now();
378+
377379
metrics
378380
.requests
379381
.get_or_create(&AccountLabel {
@@ -404,6 +406,16 @@ pub async fn process_event_with_backoff(
404406
tracing::error!("Failed to process event: {:?}", e);
405407
}
406408
}
409+
410+
let duration_ms = start_time.elapsed().as_millis() as f64;
411+
metrics
412+
.request_duration_ms
413+
.get_or_create(&AccountLabel {
414+
chain_id: chain_state.id.clone(),
415+
address: chain_state.provider_address.to_string(),
416+
})
417+
.observe(duration_ms);
418+
407419
metrics
408420
.requests_processed
409421
.get_or_create(&AccountLabel {

0 commit comments

Comments
 (0)