@@ -8,11 +8,8 @@ use conduit::{header, Host, RequestExt, Scheme, StatusCode};
8
8
use conduit_cookie:: RequestSession ;
9
9
use sentry:: Level ;
10
10
11
- use std:: cell:: RefCell ;
12
- use std:: collections:: HashMap ;
13
11
use std:: fmt:: { self , Display , Formatter } ;
14
- use std:: rc:: Rc ;
15
- use std:: time:: { Duration , Instant , SystemTime , UNIX_EPOCH } ;
12
+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
16
13
17
14
const SLOW_REQUEST_THRESHOLD_MS : u64 = 1000 ;
18
15
@@ -94,34 +91,6 @@ pub fn add_custom_metadata<V: Display>(req: &mut dyn RequestExt, key: &'static s
94
91
}
95
92
}
96
93
97
- #[ derive( Debug , Clone ) ]
98
- pub struct TimingRecorder {
99
- sections : Rc < RefCell < HashMap < & ' static str , Duration > > > ,
100
- }
101
-
102
- impl TimingRecorder {
103
- pub fn new ( ) -> Self {
104
- Self {
105
- sections : Rc :: new ( RefCell :: new ( HashMap :: new ( ) ) ) ,
106
- }
107
- }
108
-
109
- pub fn record < R > ( & self , name : & ' static str , f : impl FnOnce ( ) -> R ) -> R {
110
- let start = Instant :: now ( ) ;
111
- let res = f ( ) ;
112
- self . sections
113
- . borrow_mut ( )
114
- . insert ( name, Instant :: now ( ) - start) ;
115
- res
116
- }
117
- }
118
-
119
- impl Default for TimingRecorder {
120
- fn default ( ) -> Self {
121
- Self :: new ( )
122
- }
123
- }
124
-
125
94
fn report_to_sentry ( req : & dyn RequestExt , res : & AfterResult , response_time : u64 ) {
126
95
let ( message, level) = match res {
127
96
Err ( e) => ( e. to_string ( ) , Level :: Error ) ,
@@ -255,17 +224,6 @@ impl Display for RequestLine<'_> {
255
224
256
225
if self . response_time > SLOW_REQUEST_THRESHOLD_MS {
257
226
line. add_marker ( "SLOW REQUEST" ) ?;
258
-
259
- if let Some ( timings) = self . req . extensions ( ) . find :: < TimingRecorder > ( ) {
260
- for ( section, duration) in timings. sections . borrow ( ) . iter ( ) {
261
- line. add_quoted_field (
262
- format ! ( "timing_{}" , section) ,
263
- // Debug formatting rounds the duration to the most useful unit and adds
264
- // the unit suffix. For example: 1.20s, 10.00ms, 8.35ns
265
- format ! ( "{:.2?}" , duration) ,
266
- ) ?;
267
- }
268
- }
269
227
}
270
228
271
229
Ok ( ( ) )
0 commit comments