11use crate :: config:: Config ;
22use crate :: key_prefix:: KeyPrefix ;
33use crate :: stats:: Result ;
4- use crate :: utils:: get_masked_dsn ;
4+ use crate :: utils:: get_dsn_host ;
55use prometheus_client:: encoding:: text:: encode;
66use prometheus_client:: encoding:: EncodeLabelSet ;
77use prometheus_client:: metrics:: family:: Family ;
88use prometheus_client:: metrics:: gauge:: Gauge ;
9- use prometheus_client:: metrics:: histogram:: { exponential_buckets, Histogram } ;
109use prometheus_client:: registry:: Registry ;
1110use std:: io:: Cursor ;
1211use std:: thread;
@@ -17,10 +16,7 @@ lazy_static! {
1716 static ref KEYS_COUNT_BY_PREFIX : Family <KeyPrefixLabel , Gauge > =
1817 Family :: <KeyPrefixLabel , Gauge >:: default ( ) ;
1918 static ref ALL_KEYS_COUNT : Family <DsnLabel , Gauge > = Family :: <DsnLabel , Gauge >:: default ( ) ;
20- static ref SCAN_DURATION : Family <DsnLabel , Histogram > =
21- Family :: <DsnLabel , Histogram >:: new_with_constructor( || Histogram :: new(
22- exponential_buckets( 10.0 , 1.5 , 20 )
23- ) ) ;
19+ static ref SCAN_DURATION : Family <DsnLabel , Gauge > = Family :: <DsnLabel , Gauge >:: default ( ) ;
2420 static ref REGISTRY : Registry = make_registry( ) ;
2521}
2622
@@ -49,13 +45,13 @@ pub fn start_metrics_server(port: u16) -> JoinHandle<()> {
4945
5046pub fn update_metrics ( config : & Config , result : & Result ) {
5147 KEYS_COUNT_BY_PREFIX . clear ( ) ;
52- let dsn = get_masked_dsn ( & config. dsn ) ;
48+ let dsn = get_dsn_host ( & config. dsn ) ;
5349
5450 let dsn_label = DsnLabel { dsn : dsn. clone ( ) } ;
5551
5652 SCAN_DURATION
5753 . get_or_create ( & dsn_label)
58- . observe ( result. took . as_secs_f64 ( ) ) ;
54+ . set ( result. took . as_secs ( ) as i64 ) ;
5955 ALL_KEYS_COUNT
6056 . get_or_create ( & dsn_label)
6157 . set ( result. root_prefix . keys_count as i64 ) ;
0 commit comments