4
4
// SPDX-License-Identifier: AGPL-3.0-only
5
5
// Please see LICENSE in the repository root for full details.
6
6
7
- use std:: { convert:: Infallible , net:: IpAddr , sync:: Arc , time :: Instant } ;
7
+ use std:: { convert:: Infallible , net:: IpAddr , sync:: Arc } ;
8
8
9
9
use axum:: extract:: { FromRef , FromRequestParts } ;
10
10
use ipnetwork:: IpNetwork ;
@@ -19,10 +19,12 @@ use mas_keystore::{Encrypter, Keystore};
19
19
use mas_matrix:: HomeserverConnection ;
20
20
use mas_policy:: { Policy , PolicyFactory } ;
21
21
use mas_router:: UrlBuilder ;
22
- use mas_storage:: { BoxClock , BoxRepository , BoxRepositoryFactory , BoxRng , SystemClock , RepositoryFactory } ;
22
+ use mas_storage:: {
23
+ BoxClock , BoxRepository , BoxRepositoryFactory , BoxRng , RepositoryFactory , SystemClock ,
24
+ } ;
23
25
use mas_storage_pg:: PgRepositoryFactory ;
24
26
use mas_templates:: Templates ;
25
- use opentelemetry:: { KeyValue , metrics :: Histogram } ;
27
+ use opentelemetry:: KeyValue ;
26
28
use rand:: SeedableRng ;
27
29
use sqlx:: PgPool ;
28
30
use tracing:: Instrument ;
@@ -47,7 +49,6 @@ pub struct AppState {
47
49
pub activity_tracker : ActivityTracker ,
48
50
pub trusted_proxies : Vec < IpNetwork > ,
49
51
pub limiter : Limiter ,
50
- pub conn_acquisition_histogram : Option < Histogram < u64 > > ,
51
52
}
52
53
53
54
impl AppState {
@@ -76,14 +77,6 @@ impl AppState {
76
77
instrument. observe ( i64:: from ( max_conn) , & [ ] ) ;
77
78
} )
78
79
. build ( ) ;
79
-
80
- // Track the connection acquisition time
81
- let histogram = METER
82
- . u64_histogram ( "db.client.connections.create_time" )
83
- . with_description ( "The time it took to create a new connection." )
84
- . with_unit ( "ms" )
85
- . build ( ) ;
86
- self . conn_acquisition_histogram = Some ( histogram) ;
87
80
}
88
81
89
82
/// Init the metadata cache in the background
@@ -371,17 +364,7 @@ impl FromRequestParts<AppState> for BoxRepository {
371
364
_parts : & mut axum:: http:: request:: Parts ,
372
365
state : & AppState ,
373
366
) -> Result < Self , Self :: Rejection > {
374
- let start = Instant :: now ( ) ;
375
367
let repo = state. repository_factory . create ( ) . await ?;
376
-
377
- // Measure the time it took to create the connection
378
- let duration = start. elapsed ( ) ;
379
- let duration_ms = duration. as_millis ( ) . try_into ( ) . unwrap_or ( u64:: MAX ) ;
380
-
381
- if let Some ( histogram) = & state. conn_acquisition_histogram {
382
- histogram. record ( duration_ms, & [ ] ) ;
383
- }
384
-
385
368
Ok ( repo)
386
369
}
387
370
}
0 commit comments