@@ -25,7 +25,7 @@ use prometheus_client::metrics::histogram::{exponential_buckets, Histogram};
25
25
use prometheus_client:: registry:: { Registry , Unit } ;
26
26
27
27
pub struct Metrics {
28
- query_result_get_record_ok : Histogram ,
28
+ query_result_get_record_ok : Counter ,
29
29
query_result_get_record_error : Family < GetRecordResult , Counter > ,
30
30
31
31
query_result_get_closest_peers_ok : Histogram ,
@@ -48,7 +48,7 @@ impl Metrics {
48
48
pub fn new ( registry : & mut Registry ) -> Self {
49
49
let sub_registry = registry. sub_registry_with_prefix ( "kad" ) ;
50
50
51
- let query_result_get_record_ok = Histogram :: new ( exponential_buckets ( 1.0 , 2.0 , 10 ) ) ;
51
+ let query_result_get_record_ok = Counter :: default ( ) ;
52
52
sub_registry. register (
53
53
"query_result_get_record_ok" ,
54
54
"Number of records returned by a successful Kademlia get record query." ,
@@ -162,7 +162,7 @@ impl Metrics {
162
162
impl super :: Recorder < libp2p_kad:: KademliaEvent > for Metrics {
163
163
fn record ( & self , event : & libp2p_kad:: KademliaEvent ) {
164
164
match event {
165
- libp2p_kad:: KademliaEvent :: OutboundQueryCompleted { result, stats, .. } => {
165
+ libp2p_kad:: KademliaEvent :: OutboundQueryProgressed { result, stats, .. } => {
166
166
self . query_result_num_requests
167
167
. get_or_create ( & result. into ( ) )
168
168
. observe ( stats. num_requests ( ) . into ( ) ) ;
@@ -180,9 +180,10 @@ impl super::Recorder<libp2p_kad::KademliaEvent> for Metrics {
180
180
181
181
match result {
182
182
libp2p_kad:: QueryResult :: GetRecord ( result) => match result {
183
- Ok ( ok) => self
184
- . query_result_get_record_ok
185
- . observe ( ok. records . len ( ) as f64 ) ,
183
+ Ok ( libp2p_kad:: GetRecordOk :: FoundRecord ( _) ) => {
184
+ self . query_result_get_record_ok . inc ( ) ;
185
+ }
186
+ Ok ( libp2p_kad:: GetRecordOk :: FinishedWithNoAdditionalRecord { .. } ) => { }
186
187
Err ( error) => {
187
188
self . query_result_get_record_error
188
189
. get_or_create ( & error. into ( ) )
@@ -200,9 +201,13 @@ impl super::Recorder<libp2p_kad::KademliaEvent> for Metrics {
200
201
}
201
202
} ,
202
203
libp2p_kad:: QueryResult :: GetProviders ( result) => match result {
203
- Ok ( ok) => self
204
- . query_result_get_providers_ok
205
- . observe ( ok. providers . len ( ) as f64 ) ,
204
+ Ok ( libp2p_kad:: GetProvidersOk :: FoundProviders { providers, .. } ) => {
205
+ self . query_result_get_providers_ok
206
+ . observe ( providers. len ( ) as f64 ) ;
207
+ }
208
+ Ok ( libp2p_kad:: GetProvidersOk :: FinishedWithNoAdditionalRecord {
209
+ ..
210
+ } ) => { }
206
211
Err ( error) => {
207
212
self . query_result_get_providers_error
208
213
. get_or_create ( & error. into ( ) )
0 commit comments