Skip to content

Commit

Permalink
feat: Add constants from chain to metrics (#26)
Browse files Browse the repository at this point in the history
* add constants

* use info

* fix info

---------

Co-authored-by: Anatolios Laskaris <[email protected]>
  • Loading branch information
DieMyst and nahsi authored Oct 18, 2024
1 parent d7a7705 commit 81d778a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
24 changes: 24 additions & 0 deletions graph_node_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ def collect_graph_networks_metrics(client):
providersTotal
effectorsTotal
capacityCommitmentsTotal
usdCollateralPerUnit
minRewardPerEpoch
maxRewardPerEpoch
vestingPeriodDuration
vestingPeriodCount
maxProofsPerEpoch
withdrawEpochsAfterFailed
difficulty
}
}
''')
Expand All @@ -267,6 +275,14 @@ def collect_graph_networks_metrics(client):
providersTotal = graphNetwork['providersTotal']
effectorsTotal = graphNetwork['effectorsTotal']
commitmentCreatedCount = graphNetwork['capacityCommitmentsTotal']
usdCollateralPerUnit = graphNetwork['usdCollateralPerUnit']
minRewardPerEpoch = graphNetwork['minRewardPerEpoch']
maxRewardPerEpoch = graphNetwork['maxRewardPerEpoch']
vestingPeriodDuration = graphNetwork['vestingPeriodDuration']
vestingPeriodCount = graphNetwork['vestingPeriodCount']
maxProofsPerEpoch = graphNetwork['maxProofsPerEpoch']
withdrawEpochsAfterFailed = graphNetwork['withdrawEpochsAfterFailed']
difficulty = graphNetwork['difficulty']

FLT_PRICE.set(fltPrice)
SLASHING_RATE.set(slashingRate)
Expand All @@ -280,6 +296,14 @@ def collect_graph_networks_metrics(client):
PROVIDERS_TOTAL.set(providersTotal)
EFFECTORS_TOTAL.set(effectorsTotal)
COMMITMENT_CREATED_COUNT.set(commitmentCreatedCount)
USD_COLLATERAL_PER_UNIT.set(usdCollateralPerUnit)
MIN_REWARD_PER_EPOCH.set(minRewardPerEpoch)
MAX_REWARD_PER_EPOCH.set(maxRewardPerEpoch)
VESTING_PERIOD_DURATION.set(vestingPeriodDuration)
VESTING_PERIOD_COUNT.set(vestingPeriodCount)
MAX_PROOFS_PER_EPOCH.set(maxProofsPerEpoch)
WITHDRAW_EPOCHS_AFTER_FAILED.set(withdrawEpochsAfterFailed)
INFO.info({'name': 'difficulty', 'difficulty': difficulty})

except Exception as e:
logger.error(f"Error collecting graph networks: {e}")
Expand Down
12 changes: 10 additions & 2 deletions metrics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from prometheus_client import Gauge, CollectorRegistry
from prometheus_client import Gauge, CollectorRegistry, Info
import config_loader
import os

Expand Down Expand Up @@ -27,6 +27,13 @@
REWARD_BALANCE_FLT = Gauge('fluence_network_reward_balance', 'Amount of FLT designated to Capacity Rewards on Diamond (scaled to ether)', registry=registry)

FLT_PRICE = Gauge("fluence_network_flt_price", "Price of FLT in USD", registry=registry)
USD_COLLATERAL_PER_UNIT = Gauge("fluence_network_usd_collateral_per_unit", "USD collateral per compute unit", registry=registry)
MIN_REWARD_PER_EPOCH = Gauge("fluence_network_min_reward_per_epoch", "Min reward per epoch", registry=registry)
MAX_REWARD_PER_EPOCH = Gauge("fluence_network_max_reward_per_epoch", "Max reward per epoch", registry=registry)
VESTING_PERIOD_DURATION = Gauge("fluence_network_vesting_period_duration", "Vesting period duration", registry=registry)
VESTING_PERIOD_COUNT = Gauge("fluence_network_vesting_period_count", "Vesting period count", registry=registry)
MAX_PROOFS_PER_EPOCH = Gauge("fluence_network_max_proofs_per_epoch", "Maximum proofs per epoch", registry=registry)
WITHDRAW_EPOCHS_AFTER_FAILED = Gauge("fluence_network_withdraw_epochs_after_failed", "Withdraw epochs after failed", registry=registry)
SLASHING_RATE = Gauge("fluence_network_slashing_rate", "Slashing rate in percents", registry=registry)
CORE_EPOCH_DURATION = Gauge("fluence_network_core_epoch_duration", "Epoch Duration in seconds", registry=registry)
CAPACITY_MAX_FAILED_RATIO = Gauge("fluence_network_capacity_max_failed_ratio", "CC maximum failed epochs", registry=registry)
Expand All @@ -39,9 +46,10 @@
EFFECTORS_TOTAL = Gauge("fluence_network_effectors_total", "Total count of effectors", registry=registry)
COMMITMENT_CREATED_COUNT = Gauge("fluence_network_commitment_created_count", "Total count of CommitmentCreated events", registry=registry)

INFO = Info("fluence_network_info", "Info about network", registry=registry)
FLUENCE_NFT_SUBGRAPH_LATEST_BLOCK = Gauge('fluence_network_nft_subgraph_latest_block','The latest block number seen by subgraph for NFT', registry=registry)
NFTS_TOKENS_TOTAL = Gauge("fluence_network_nfts_tokens_total", "Total count of NFTs", registry=registry)
NFTS_TOKENS_ON_SALE = Gauge("fluence_network_nfts_tokens_on_sale", "Total count of NFTs for sale", registry=registry)
NFTS_TOTAL_SOLD = Gauge("fluence_network_nfts_total_sold", "Total count of NFTs sold", registry=registry)
NFTS_TOTAL_VOLUME = Gauge("fluence_network_nfts_total_volume", "Total volume of NFTs", registry=registry)
NFTS_FLOOR_PRICE = Gauge("fluence_network_nfts_floor_price", "Floor price of NFTs", registry=registry)
NFTS_FLOOR_PRICE = Gauge("fluence_network_nfts_floor_price", "Floor price of NFTs", registry=registry)

0 comments on commit 81d778a

Please sign in to comment.