17
17
//! As a rule of thumb, if the metric requires a database query to be updated it's probably a
18
18
//! service-level metric, and you should add it to `src/metrics/service.rs` instead.
19
19
20
+ use crate :: app:: App ;
20
21
use crate :: metrics:: macros:: metrics;
21
- use crate :: { app:: App , db:: DieselPool } ;
22
22
use deadpool_diesel:: postgres:: Pool ;
23
23
use prometheus:: {
24
24
proto:: MetricFamily , HistogramVec , IntCounter , IntCounterVec , IntGauge , IntGaugeVec ,
@@ -53,11 +53,6 @@ metrics! {
53
53
impl InstanceMetrics {
54
54
pub fn gather ( & self , app : & App ) -> prometheus:: Result < Vec < MetricFamily > > {
55
55
// 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
-
61
56
self . refresh_async_pool_stats ( "async_primary" , & app. deadpool_primary ) ?;
62
57
if let Some ( follower) = & app. deadpool_replica {
63
58
self . refresh_async_pool_stats ( "async_follower" , follower) ?;
@@ -66,19 +61,6 @@ impl InstanceMetrics {
66
61
Ok ( self . registry . gather ( ) )
67
62
}
68
63
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
-
82
64
fn refresh_async_pool_stats ( & self , name : & str , pool : & Pool ) -> prometheus:: Result < ( ) > {
83
65
let status = pool. status ( ) ;
84
66
0 commit comments