WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit f508236

Browse files
authored
Merge pull request #401 from superfly/gorbak/fix-ro-metrics
Distringuish RO/RW for other queries
2 parents c468625 + 8a45924 commit f508236

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

crates/corro-types/src/sqlite.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ fn handle_query_metrics(elapsed: Duration) {
6464
}
6565
}
6666

67-
let mut other_queries_count = 0u64;
68-
let mut other_queries_nanos = 0u128;
67+
let mut other_ro_queries_count = 0u64;
68+
let mut other_ro_queries_nanos = 0u128;
69+
let mut other_rw_queries_count = 0u64;
70+
let mut other_rw_queries_nanos = 0u128;
6971
for ((query_raw, readonly), (total_query_count, total_query_nanos)) in aggregated.into_iter() {
7072
let total_query_ms = (total_query_nanos / 1_000_000) as u64;
7173
let ms_per_second = total_query_ms as f64 / elapsed.as_secs_f64();
@@ -90,16 +92,26 @@ fn handle_query_metrics(elapsed: Duration) {
9092
counter!("corro.db.query.count", "query" => query.clone(), "readonly" => readonly.to_string()).increment(total_query_count);
9193
} else {
9294
// For all other queries let's just sum them up
93-
other_queries_count += total_query_count;
94-
other_queries_nanos += total_query_nanos;
95+
if readonly {
96+
other_ro_queries_count += total_query_count;
97+
other_ro_queries_nanos += total_query_nanos;
98+
} else {
99+
other_rw_queries_count += total_query_count;
100+
other_rw_queries_nanos += total_query_nanos;
101+
}
95102
}
96103
}
97-
let other_queries_ms = (other_queries_nanos / 1_000_000) as u64;
98104
let other_queries_name = "OTHER";
105+
let other_ro_queries_ms = (other_ro_queries_nanos / 1_000_000) as u64;
106+
counter!("corro.db.query.ms", "query" => other_queries_name , "readonly" => "true")
107+
.increment(other_ro_queries_ms);
108+
counter!("corro.db.query.count", "query" => other_queries_name, "readonly" => "true")
109+
.increment(other_ro_queries_count);
110+
let other_rw_queries_ms = (other_rw_queries_nanos / 1_000_000) as u64;
99111
counter!("corro.db.query.ms", "query" => other_queries_name , "readonly" => "false")
100-
.increment(other_queries_ms);
112+
.increment(other_rw_queries_ms);
101113
counter!("corro.db.query.count", "query" => other_queries_name, "readonly" => "false")
102-
.increment(other_queries_count);
114+
.increment(other_rw_queries_count);
103115
}
104116

105117
fn tracing_callback_ro(ev: rusqlite::trace::TraceEvent) {

0 commit comments

Comments
 (0)