Skip to content

Commit 99a6f00

Browse files
committed
metrics: Remove sync database pools
These are not used anywhere anymore.
1 parent 77d55e9 commit 99a6f00

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

src/metrics/instance.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
//! As a rule of thumb, if the metric requires a database query to be updated it's probably a
1818
//! service-level metric, and you should add it to `src/metrics/service.rs` instead.
1919
20+
use crate::app::App;
2021
use crate::metrics::macros::metrics;
21-
use crate::{app::App, db::DieselPool};
2222
use deadpool_diesel::postgres::Pool;
2323
use prometheus::{
2424
proto::MetricFamily, HistogramVec, IntCounter, IntCounterVec, IntGauge, IntGaugeVec,
@@ -53,11 +53,6 @@ metrics! {
5353
impl InstanceMetrics {
5454
pub fn gather(&self, app: &App) -> prometheus::Result<Vec<MetricFamily>> {
5555
// Database pool stats
56-
self.refresh_pool_stats("primary", &app.primary_database)?;
57-
if let Some(follower) = &app.read_only_replica_database {
58-
self.refresh_pool_stats("follower", follower)?;
59-
}
60-
6156
self.refresh_async_pool_stats("async_primary", &app.deadpool_primary)?;
6257
if let Some(follower) = &app.deadpool_replica {
6358
self.refresh_async_pool_stats("async_follower", follower)?;
@@ -66,19 +61,6 @@ impl InstanceMetrics {
6661
Ok(self.registry.gather())
6762
}
6863

69-
fn refresh_pool_stats(&self, name: &str, pool: &DieselPool) -> prometheus::Result<()> {
70-
let state = pool.state();
71-
72-
self.database_idle_conns
73-
.get_metric_with_label_values(&[name])?
74-
.set(state.idle_connections as i64);
75-
self.database_used_conns
76-
.get_metric_with_label_values(&[name])?
77-
.set((state.connections - state.idle_connections) as i64);
78-
79-
Ok(())
80-
}
81-
8264
fn refresh_async_pool_stats(&self, name: &str, pool: &Pool) -> prometheus::Result<()> {
8365
let status = pool.status();
8466

0 commit comments

Comments
 (0)