Skip to content

Commit cd70475

Browse files
authored
feat: Current epoch units stats (#53)
* diamond address fix * current epoch startTime
1 parent f1fcf62 commit cd70475

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

graph_node_metrics.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ def collect_current_epoch_proof_stats(client, providers):
328328
"""Collect proof stats for the current epoch."""
329329
try:
330330
current_epoch = get_current_epoch(client)
331+
332+
CORE_CURRENT_EPOCH_START.set(current_epoch['startTimestamp'])
333+
331334
network_info = get_network_info(client)
332335
if not current_epoch or not network_info:
333336
logger.warning("Failed to get current epoch or network info")
@@ -353,6 +356,8 @@ def collect_current_epoch_proof_stats(client, providers):
353356
totalFailCount
354357
id
355358
activeUnitCount
359+
exitedUnitCount
360+
computeUnitsWithMinRequiredProofsSubmittedCounter
356361
capacityCommitment {{
357362
id
358363
provider {{
@@ -385,6 +390,8 @@ def collect_current_epoch_proof_stats(client, providers):
385390
provider_name = stat['capacityCommitment']['provider']['name']
386391
cc_id = stat['capacityCommitment']['id']
387392
active_unit_count = int(stat['activeUnitCount'])
393+
exited_unit_count = int(stat['exitedUnitCount'])
394+
finished_unit_count = int(stat['computeUnitsWithMinRequiredProofsSubmittedCounter'])
388395

389396
if provider_id not in provider_ids:
390397
continue
@@ -402,7 +409,15 @@ def collect_current_epoch_proof_stats(client, providers):
402409
COMMITMENT_CURRENT_EPOCH_MIN_PROJECTED_PROOFS.labels(
403410
cc_id=cc_id, provider_id=provider_id, provider_name=provider_name
404411
).set(min_projected_proofs)
405-
412+
COMMITMENT_CURRENT_UNITS.labels(
413+
cc_id=cc_id, provider_id=provider_id, provider_name=provider_name, status='active'
414+
).set(active_unit_count)
415+
COMMITMENT_CURRENT_UNITS.labels(
416+
cc_id=cc_id, provider_id=provider_id, provider_name=provider_name, status='exited'
417+
).set(exited_unit_count)
418+
COMMITMENT_CURRENT_UNITS.labels(
419+
cc_id=cc_id, provider_id=provider_id, provider_name=provider_name, status='sent_enough_proofs'
420+
).set(finished_unit_count)
406421
except Exception as e:
407422
logger.error(f"Error collecting proof stats: {e}")
408423
raise

metrics.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
MAX_PROOFS_PER_EPOCH = Gauge("fluence_network_max_proofs_per_epoch", "Maximum proofs per epoch", registry=registry)
4242
WITHDRAW_EPOCHS_AFTER_FAILED = Gauge("fluence_network_withdraw_epochs_after_failed", "Withdraw epochs after failed", registry=registry)
4343
SLASHING_RATE = Gauge("fluence_network_slashing_rate", "Slashing rate in percents", registry=registry)
44+
4445
CORE_EPOCH_DURATION = Gauge("fluence_network_core_epoch_duration", "Epoch Duration in seconds", registry=registry)
46+
CORE_CURRENT_EPOCH_START = Gauge("fluence_network_core_current_epoch_start", "Current epoch start", registry=registry)
47+
4548
CAPACITY_MAX_FAILED_RATIO = Gauge("fluence_network_capacity_max_failed_ratio", "CC maximum failed epochs", registry=registry)
4649
USD_TARGET_REVENUE_PER_EPOCH = Gauge("fluence_network_usd_target_revenue_per_epoch", "Target revenue per CC per epoch in non-scaled USD", registry=registry)
4750
MIN_REQUIRED_PROOFS_PER_EPOCH = Gauge("fluence_network_min_required_proofs_per_epoch", "Minimum proofs per CU per epoch", registry=registry)
@@ -57,5 +60,6 @@
5760
COMMITMENT_CURRENT_EPOCH_SUBMITTED_PROOFS = Gauge("fluence_network_cc_current_epoch_submitted_proofs", "Current epoch submitted proofs", ['cc_id','provider_id','provider_name'], registry=registry)
5861
COMMITMENT_CURRENT_EPOCH_MIN_PROJECTED_PROOFS = Gauge("fluence_network_cc_current_epoch_min_projected_proofs", "Current epoch projected proofs (min)", ['cc_id','provider_id','provider_name'], registry=registry)
5962
COMMITMENT_CURRENT_EPOCH_MAX_PROJECTED_PROOFS = Gauge("fluence_network_cc_current_epoch_max_projected_proofs", "Current epoch projected proofs (max)", ['cc_id','provider_id','provider_name'], registry=registry)
63+
COMMITMENT_CURRENT_UNITS = Gauge("fluence_network_cc_current_epoch_cus", "Current epoch CUs stat", ['cc_id','provider_id','provider_name','status'], registry=registry)
6064

6165
INFO = Info("fluence_network_info", "Info about network", registry=registry)

0 commit comments

Comments
 (0)