Skip to content

Commit d6de3e6

Browse files
committed
Update mobc and metrics crates
mobc update includes fixes from importcjj/mobc#99 Rest of the PR is update to new api of the `metrics` crate. Close prisma/team-orm#1317
1 parent 08713a9 commit d6de3e6

File tree

14 files changed

+165
-158
lines changed

14 files changed

+165
-158
lines changed

Diff for: Cargo.lock

+74-50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ napi = { version = "2.15.1", default-features = false, features = [
6464
"serde-json",
6565
] }
6666
napi-derive = "2.15.0"
67+
metrics = "0.23.0"
6768
js-sys = { version = "0.3" }
6869
rand = { version = "0.8" }
6970
regex = { version = "1", features = ["std"] }

Diff for: quaint/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ tracing-core = "0.1"
7676
async-trait.workspace = true
7777
thiserror = "1.0"
7878
num_cpus = "1.12"
79-
metrics = "0.18"
79+
metrics.workspace = true
8080
futures = "0.3"
8181
url.workspace = true
8282
hex = "0.4"
@@ -92,7 +92,7 @@ serde_json.workspace = true
9292
native-tls = { version = "0.2", optional = true }
9393
bit-vec = { version = "0.6.1", optional = true }
9494
bytes = { version = "1.0", optional = true }
95-
mobc = { version = "0.8", optional = true }
95+
mobc = { git="https://github.com/SevInf/mobc.git", branch = "metrics-guards", optional = true }
9696
serde = { version = "1.0" }
9797
sqlformat = { version = "0.2.3", optional = true }
9898
uuid.workspace = true

Diff for: quaint/src/connector/metrics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ where
4646
trace_query(query, params, result, &start);
4747
}
4848

49-
histogram!(format!("{tag}.query.time"), start.elapsed_time());
50-
histogram!("prisma_datasource_queries_duration_histogram_ms", start.elapsed_time());
51-
increment_counter!("prisma_datasource_queries_total");
49+
histogram!(format!("{tag}.query.time")).record(start.elapsed_time());
50+
histogram!("prisma_datasource_queries_duration_histogram_ms").record(start.elapsed_time());
51+
counter!("prisma_datasource_queries_total").increment(1);
5252

5353
res
5454
}
@@ -74,7 +74,7 @@ where
7474
result,
7575
);
7676

77-
histogram!("pool.check_out", start.elapsed_time());
77+
histogram!("pool.check_out").record(start.elapsed_time());
7878

7979
res
8080
}

Diff for: quaint/src/connector/transaction.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
error::{Error, ErrorKind},
55
};
66
use async_trait::async_trait;
7-
use metrics::{decrement_gauge, increment_gauge};
7+
use metrics::gauge;
88
use std::{fmt, str::FromStr};
99

1010
extern crate metrics as metrics;
@@ -62,7 +62,7 @@ impl<'a> DefaultTransaction<'a> {
6262

6363
inner.server_reset_query(&this).await?;
6464

65-
increment_gauge!("prisma_client_queries_active", 1.0);
65+
gauge!("prisma_client_queries_active").increment(1.0);
6666
Ok(this)
6767
}
6868
}
@@ -71,15 +71,15 @@ impl<'a> DefaultTransaction<'a> {
7171
impl<'a> Transaction for DefaultTransaction<'a> {
7272
/// Commit the changes to the database and consume the transaction.
7373
async fn commit(&self) -> crate::Result<()> {
74-
decrement_gauge!("prisma_client_queries_active", 1.0);
74+
gauge!("prisma_client_queries_active").decrement(1.0);
7575
self.inner.raw_cmd("COMMIT").await?;
7676

7777
Ok(())
7878
}
7979

8080
/// Rolls back the changes to the database.
8181
async fn rollback(&self) -> crate::Result<()> {
82-
decrement_gauge!("prisma_client_queries_active", 1.0);
82+
gauge!("prisma_client_queries_active").decrement(1.0);
8383
self.inner.raw_cmd("ROLLBACK").await?;
8484

8585
Ok(())

0 commit comments

Comments
 (0)