Skip to content

Commit

Permalink
feat: configurable caching for postgres with support for tracing (#5082)
Browse files Browse the repository at this point in the history
* feat: configurable caching with support for tracing

* fix: correct TypedQuery creation

* fix: store columns in TypedQuery

* fix: store column names as well

* fix: define aliases and fix some references to PostgreSql

* chore: doc comments and cleanup

* chore: doc comment adjustments and renames

* test: cover the queries and caches

* fix: actually pass tracing flag

* refactor: merge the two prepared query caches

* fix: make sure to return the caller-provided sql with TypedQuery

* chore: get rid of some unneeded accessors

* chore: update assertion text

* doc: clarify comment

* chore: use rsplit because we expect traceparent at the end

* doc: correct comment

* test: cover higher capacity in the tests

* [integration]

* chore: correct typo

* fix: remove unneeded outlives trick

* chore: less annoying trace message

* chore: switch over to tokio mutex

* refactor: use a NoOp hasher
  • Loading branch information
jacek-prisma authored Dec 13, 2024
1 parent 81600e1 commit 99168c5
Show file tree
Hide file tree
Showing 10 changed files with 790 additions and 207 deletions.
29 changes: 14 additions & 15 deletions quaint/src/connector/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,19 @@ struct QueryForTracing<'a>(&'a str);

impl fmt::Display for QueryForTracing<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let query = self
.0
.split_once("/* traceparent=")
.map_or(self.0, |(str, remainder)| {
if remainder
.split_once("*/")
.is_some_and(|(_, suffix)| suffix.trim_end().is_empty())
{
str
} else {
self.0
}
})
.trim();
write!(f, "{query}")
write!(f, "{}", strip_query_traceparent(self.0))
}
}

pub(super) fn strip_query_traceparent(query: &str) -> &str {
query.rsplit_once("/* traceparent=").map_or(query, |(str, remainder)| {
if remainder
.split_once("*/")
.is_some_and(|(_, suffix)| suffix.trim_end().is_empty())
{
str.trim_end()
} else {
query
}
})
}
Loading

0 comments on commit 99168c5

Please sign in to comment.