mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 12:48:00 +00:00
client/authority-discovery: Instrument code with Prometheus (#5195)
* client/authority-discovery: Instrument code with Prometheus Introduce Prometheus metrics into the authority discovery module enabling one to observe: - authority_discovery_times_published_total - authority_discovery_amount_external_addresses_last_published - authority_discovery_times_requested_total - authority_discovery_dht_event_received * client/authority-discovery/src/lib.rs: Reword metric help texts Co-Authored-By: Ashley <ashley.ruglys@gmail.com> * client/authority-discovery/src/lib.rs: Reword metric help text Co-Authored-By: Ashley <ashley.ruglys@gmail.com> * client/authority-discovery/tests: Fix struct instantiation + basic test Co-authored-by: Ashley <ashley.ruglys@gmail.com>
This commit is contained in:
@@ -275,6 +275,29 @@ impl NetworkStateInfo for TestNetwork {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_registers_metrics() {
|
||||
let (_dht_event_tx, dht_event_rx) = channel(1000);
|
||||
let network: Arc<TestNetwork> = Arc::new(Default::default());
|
||||
let key_store = KeyStore::new();
|
||||
let test_api = Arc::new(TestApi {
|
||||
authorities: vec![],
|
||||
});
|
||||
|
||||
let registry = prometheus_endpoint::Registry::new();
|
||||
|
||||
AuthorityDiscovery::new(
|
||||
test_api,
|
||||
network.clone(),
|
||||
vec![],
|
||||
key_store,
|
||||
dht_event_rx.boxed(),
|
||||
Some(registry.clone()),
|
||||
);
|
||||
|
||||
assert!(registry.gather().len() > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn publish_ext_addresses_puts_record_on_dht() {
|
||||
let (_dht_event_tx, dht_event_rx) = channel(1000);
|
||||
@@ -294,6 +317,7 @@ fn publish_ext_addresses_puts_record_on_dht() {
|
||||
vec![],
|
||||
key_store,
|
||||
dht_event_rx.boxed(),
|
||||
None,
|
||||
);
|
||||
|
||||
authority_discovery.publish_ext_addresses().unwrap();
|
||||
@@ -324,6 +348,7 @@ fn request_addresses_of_others_triggers_dht_get_query() {
|
||||
vec![],
|
||||
key_store,
|
||||
dht_event_rx.boxed(),
|
||||
None,
|
||||
);
|
||||
|
||||
authority_discovery.request_addresses_of_others().unwrap();
|
||||
@@ -351,6 +376,7 @@ fn handle_dht_events_with_value_found_should_call_set_priority_group() {
|
||||
vec![],
|
||||
key_store,
|
||||
dht_event_rx.boxed(),
|
||||
None,
|
||||
);
|
||||
|
||||
// Create sample dht event.
|
||||
|
||||
Reference in New Issue
Block a user