client/network: Expose DHT query duration to Prometheus (#6784)

Expose duration of DHT put and get request as a Prometheus histogram.
This commit is contained in:
Max Inden
2020-08-03 10:30:06 +02:00
committed by GitHub
parent a1786a92ec
commit 1365eef4c1
3 changed files with 58 additions and 25 deletions
+11 -10
View File
@@ -145,8 +145,9 @@ pub enum BehaviourOut<B: BlockT> {
messages: Vec<(ConsensusEngineId, Bytes)>,
},
/// Event generated by a DHT.
Dht(DhtEvent),
/// Events generated by a DHT as a response to get_value or put_value requests as well as the
/// request duration.
Dht(DhtEvent, Duration),
}
impl<B: BlockT, H: ExHashT> Behaviour<B, H> {
@@ -454,17 +455,17 @@ impl<B: BlockT, H: ExHashT> NetworkBehaviourEventProcess<DiscoveryOut>
DiscoveryOut::Discovered(peer_id) => {
self.substrate.add_discovered_nodes(iter::once(peer_id));
}
DiscoveryOut::ValueFound(results) => {
self.events.push_back(BehaviourOut::Dht(DhtEvent::ValueFound(results)));
DiscoveryOut::ValueFound(results, duration) => {
self.events.push_back(BehaviourOut::Dht(DhtEvent::ValueFound(results), duration));
}
DiscoveryOut::ValueNotFound(key) => {
self.events.push_back(BehaviourOut::Dht(DhtEvent::ValueNotFound(key)));
DiscoveryOut::ValueNotFound(key, duration) => {
self.events.push_back(BehaviourOut::Dht(DhtEvent::ValueNotFound(key), duration));
}
DiscoveryOut::ValuePut(key) => {
self.events.push_back(BehaviourOut::Dht(DhtEvent::ValuePut(key)));
DiscoveryOut::ValuePut(key, duration) => {
self.events.push_back(BehaviourOut::Dht(DhtEvent::ValuePut(key), duration));
}
DiscoveryOut::ValuePutFailed(key) => {
self.events.push_back(BehaviourOut::Dht(DhtEvent::ValuePutFailed(key)));
DiscoveryOut::ValuePutFailed(key, duration) => {
self.events.push_back(BehaviourOut::Dht(DhtEvent::ValuePutFailed(key), duration));
}
DiscoveryOut::RandomKademliaStarted(protocols) => {
for protocol in protocols {