@@ -73,45 +73,15 @@ impl Repository {
7373 result
7474 }
7575
76- pub async fn recalculate_udp_avg_connect_processing_time_ns (
76+ pub async fn recalculate_udp_avg_processing_time_ns (
7777 & self ,
7878 req_processing_time : Duration ,
7979 label_set : & LabelSet ,
8080 now : DurationSinceUnixEpoch ,
8181 ) -> f64 {
8282 let mut stats_lock = self . stats . write ( ) . await ;
8383
84- let new_avg = stats_lock. recalculate_udp_avg_connect_processing_time_ns ( req_processing_time, label_set, now) ;
85-
86- drop ( stats_lock) ;
87-
88- new_avg
89- }
90-
91- pub async fn recalculate_udp_avg_announce_processing_time_ns (
92- & self ,
93- req_processing_time : Duration ,
94- label_set : & LabelSet ,
95- now : DurationSinceUnixEpoch ,
96- ) -> f64 {
97- let mut stats_lock = self . stats . write ( ) . await ;
98-
99- let new_avg = stats_lock. recalculate_udp_avg_announce_processing_time_ns ( req_processing_time, label_set, now) ;
100-
101- drop ( stats_lock) ;
102-
103- new_avg
104- }
105-
106- pub async fn recalculate_udp_avg_scrape_processing_time_ns (
107- & self ,
108- req_processing_time : Duration ,
109- label_set : & LabelSet ,
110- now : DurationSinceUnixEpoch ,
111- ) -> f64 {
112- let mut stats_lock = self . stats . write ( ) . await ;
113-
114- let new_avg = stats_lock. recalculate_udp_avg_scrape_processing_time_ns ( req_processing_time, label_set, now) ;
84+ let new_avg = stats_lock. recalculate_udp_avg_processing_time_ns ( req_processing_time, label_set, now) ;
11585
11686 drop ( stats_lock) ;
11787
@@ -354,7 +324,7 @@ mod tests {
354324 // Calculate new average with processing time of 2000ns
355325 let processing_time = Duration :: from_nanos ( 2000 ) ;
356326 let new_avg = repo
357- . recalculate_udp_avg_connect_processing_time_ns ( processing_time, & connect_labels, now)
327+ . recalculate_udp_avg_processing_time_ns ( processing_time, & connect_labels, now)
358328 . await ;
359329
360330 // Moving average: previous_avg + (new_value - previous_avg) / total_connections
@@ -401,7 +371,7 @@ mod tests {
401371 // Calculate new average with processing time of 1500ns
402372 let processing_time = Duration :: from_nanos ( 1500 ) ;
403373 let new_avg = repo
404- . recalculate_udp_avg_announce_processing_time_ns ( processing_time, & announce_labels, now)
374+ . recalculate_udp_avg_processing_time_ns ( processing_time, & announce_labels, now)
405375 . await ;
406376
407377 // Moving average: previous_avg + (new_value - previous_avg) / total_announces
@@ -442,7 +412,7 @@ mod tests {
442412 // Calculate new average with processing time of 1200ns
443413 let processing_time = Duration :: from_nanos ( 1200 ) ;
444414 let new_avg = repo
445- . recalculate_udp_avg_scrape_processing_time_ns ( processing_time, & scrape_labels, now)
415+ . recalculate_udp_avg_processing_time_ns ( processing_time, & scrape_labels, now)
446416 . await ;
447417
448418 // Moving average: previous_avg + (new_value - previous_avg) / total_scrapes
@@ -464,17 +434,17 @@ mod tests {
464434
465435 let connect_labels = LabelSet :: from ( [ ( "request_kind" , "connect" ) ] ) ;
466436 let connect_avg = repo
467- . recalculate_udp_avg_connect_processing_time_ns ( processing_time, & connect_labels, now)
437+ . recalculate_udp_avg_processing_time_ns ( processing_time, & connect_labels, now)
468438 . await ;
469439
470440 let announce_labels = LabelSet :: from ( [ ( "request_kind" , "announce" ) ] ) ;
471441 let announce_avg = repo
472- . recalculate_udp_avg_announce_processing_time_ns ( processing_time, & announce_labels, now)
442+ . recalculate_udp_avg_processing_time_ns ( processing_time, & announce_labels, now)
473443 . await ;
474444
475445 let scrape_labels = LabelSet :: from ( [ ( "request_kind" , "scrape" ) ] ) ;
476446 let scrape_avg = repo
477- . recalculate_udp_avg_scrape_processing_time_ns ( processing_time, & scrape_labels, now)
447+ . recalculate_udp_avg_processing_time_ns ( processing_time, & scrape_labels, now)
478448 . await ;
479449
480450 // With 0 total connections, the formula becomes 0 + (1000 - 0) / 0
@@ -535,7 +505,7 @@ mod tests {
535505 let large_duration = Duration :: from_secs ( 1 ) ; // 1 second = 1,000,000,000 ns
536506 let connect_labels = LabelSet :: from ( [ ( "request_kind" , "connect" ) ] ) ;
537507 let new_avg = repo
538- . recalculate_udp_avg_connect_processing_time_ns ( large_duration, & connect_labels, now)
508+ . recalculate_udp_avg_processing_time_ns ( large_duration, & connect_labels, now)
539509 . await ;
540510
541511 // Should handle large numbers without overflow
@@ -629,7 +599,7 @@ mod tests {
629599 // First calculation: no connections recorded yet, should result in infinity
630600 let processing_time_1 = Duration :: from_nanos ( 2000 ) ;
631601 let avg_1 = repo
632- . recalculate_udp_avg_connect_processing_time_ns ( processing_time_1, & connect_labels, now)
602+ . recalculate_udp_avg_processing_time_ns ( processing_time_1, & connect_labels, now)
633603 . await ;
634604
635605 assert ! (
@@ -647,7 +617,7 @@ mod tests {
647617 let processing_time_2 = Duration :: from_nanos ( 3000 ) ;
648618 let connect_labels = LabelSet :: from ( [ ( "request_kind" , "connect" ) ] ) ;
649619 let avg_2 = repo
650- . recalculate_udp_avg_connect_processing_time_ns ( processing_time_2, & connect_labels, now)
620+ . recalculate_udp_avg_processing_time_ns ( processing_time_2, & connect_labels, now)
651621 . await ;
652622
653623 // There is one connection, so the average should be:
0 commit comments