summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/metrics.c10
-rw-r--r--src/metrics.h2
-rw-r--r--src/peers.c4
3 files changed, 16 insertions, 0 deletions
diff --git a/src/metrics.c b/src/metrics.c
index 3a56837..7bac410 100644
--- a/src/metrics.c
+++ b/src/metrics.c
@@ -8,6 +8,7 @@ prom_counter_t *bytesSent = NULL;
prom_counter_t *meta = NULL;
prom_counter_t *peers = NULL;
+prom_gauge_t *current_hashes = NULL;
prom_counter_t *hashes = NULL;
prom_counter_t *hash_expired = NULL;
prom_counter_t *queries = NULL;
@@ -110,6 +111,15 @@ void metric_init() {
)
);
+ current_hashes = prom_collector_registry_must_register_metric(
+ prom_gauge_new(
+ "dht_live_hashes_total",
+ "Number of hashes with active peers",
+ 0,
+ NULL
+ )
+ );
+
hashes = prom_collector_registry_must_register_metric(
prom_counter_new(
"dht_hashes_total",
diff --git a/src/metrics.h b/src/metrics.h
index 25afcce..3155ccb 100644
--- a/src/metrics.h
+++ b/src/metrics.h
@@ -10,6 +10,7 @@ extern prom_counter_t *bytesSent;
extern prom_counter_t *meta;
extern prom_counter_t *peers;
+extern prom_gauge_t *current_hashes;
extern prom_counter_t *hashes;
extern prom_counter_t *hash_expired;
extern prom_counter_t *queries;
@@ -19,6 +20,7 @@ extern prom_gauge_t *activeNodes;
extern prom_gauge_t *requestsInFlight;
extern prom_counter_t *retries;
+
extern prom_counter_t *requestsProcessed;
void metric_init();
diff --git a/src/peers.c b/src/peers.c
index 781bc7e..6d23fff 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -105,6 +105,7 @@ int add_peer(struct infohash* infohash, struct addr* peer, time_t now) {
peer_status.peers++;
prom_counter_inc(peers, NULL);
+ prom_gauge_set(current_hashes, (double)peer_table_load, NULL);
return 0;
}
@@ -155,6 +156,9 @@ void expire_hashes(time_t now) {
// Remove the slot
entry->set = false;
+ peer_table_load--;
prom_counter_inc(hash_expired, NULL);
}
+
+ prom_gauge_set(current_hashes, (double)peer_table_load, NULL);
}