From a8d1065a1cd3e76ed43eccecebfa9fa0d52f28b5 Mon Sep 17 00:00:00 2001 From: Geod24 Date: Wed, 15 Sep 2021 18:40:47 +0900 Subject: [PATCH] Registry: Simplify and improve stats As was done for the block stats in 009b7e1e3707b5da2, we now always provide block stats no matter if we received a record or not. We also provide different values for flash and validators entry, and let the handler make the addition. --- source/agora/node/Registry.d | 25 +++++++++++++++++-------- source/agora/stats/Registry.d | 10 +++++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/source/agora/node/Registry.d b/source/agora/node/Registry.d index 96da5866444..57302bd638a 100644 --- a/source/agora/node/Registry.d +++ b/source/agora/node/Registry.d @@ -53,9 +53,6 @@ public class NameRegistry: NameRegistryAPI /// The `flash` zone private ZoneData flash; - /// Validator count stats - private RegistryStats registry_stats; - /// private FullNodeAPI agora_node; @@ -73,7 +70,7 @@ public class NameRegistry: NameRegistryAPI this.config = config; this.log = Logger(__MODULE__); this.agora_node = agora_node; - Utils.getCollectorRegistry().addCollector(&this.collectRegistryStats); + Utils.getCollectorRegistry().addCollector(&this.collectStats); const vname = "validators." ~ realm; const fname = "flash." ~ realm; @@ -95,8 +92,22 @@ public class NameRegistry: NameRegistryAPI this.flash.fill(fname, this.config.flash, serial); } - /// - mixin DefineCollectorForStats!("registry_stats", "collectRegistryStats"); + /*************************************************************************** + + Collect registry stats + + Params: + collector = the Collector to collect the stats into + + ***************************************************************************/ + + private void collectStats (Collector collector) + { + RegistryStats stats; + stats.registry_validator_record_count = this.validators.map.length; + stats.registry_flash_record_count = this.flash.map.length; + collector.collect(stats); + } /// Returns: throws if payload is not valid protected void ensureValidPayload (in RegistryPayload registry_payload, @@ -184,7 +195,6 @@ public class NameRegistry: NameRegistryAPI registry_payload.data.addresses, registry_payload.data.public_key); this.validators.map[registry_payload.data.public_key] = TypedPayload(payload_type, registry_payload); - this.registry_stats.setMetricTo!"registry_record_count"(this.validators.map.length + this.flash.map.length); } /*************************************************************************** @@ -245,7 +255,6 @@ public class NameRegistry: NameRegistryAPI registry_payload.data.public_key.toString()); this.flash.map[registry_payload.data.public_key] = TypedPayload(payload_type, registry_payload); - this.registry_stats.setMetricTo!"registry_record_count"(this.validators.map.length + this.flash.map.length); } /// diff --git a/source/agora/stats/Registry.d b/source/agora/stats/Registry.d index 0d8b66d53a6..db98a033090 100644 --- a/source/agora/stats/Registry.d +++ b/source/agora/stats/Registry.d @@ -16,10 +16,10 @@ module agora.stats.Registry; import agora.stats.Stats; /// -public struct RegistryStatsValue +public struct RegistryStats { - public ulong registry_record_count; + /// Number of records in the 'validators' zone + public ulong registry_validator_record_count; + /// Number of records in the 'flash' zone + public ulong registry_flash_record_count; } - -/// -public alias RegistryStats = Stats!(RegistryStatsValue, NoLabel);