Skip to content

Commit

Permalink
fix: collect graph networks metrics (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
folex authored Sep 28, 2024
1 parent 93ab0c1 commit 1ab34bd
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
55 changes: 55 additions & 0 deletions graph_node_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,65 @@ def collect_deal_metrics(client, provider_id, provider_name):
f"Error collecting deal metrics for provider {provider_name} (ID: {provider_id}): {e}")
raise

def collect_graph_networks_metrics(client):
try:
query = gql('''
query {
graphNetworks {
fltPrice
slashingRate
coreEpochDuration
capacityMaxFailedRatio
usdTargetRevenuePerEpoch
minRequiredProofsPerEpoch
dealsTotal
proofsTotal
offersTotal
providersTotal
effectorsTotal
capacityCommitmentsTotal
}
}
''')

response = client.execute(query)

graphNetwork = response['graphNetworks'][0]

fltPrice = graphNetwork['fltPrice']
slashingRate = graphNetwork['slashingRate']
coreEpochDuration = graphNetwork['coreEpochDuration']
capacityMaxFailedRatio = graphNetwork['capacityMaxFailedRatio']
usdTargetRevenuePerEpoch = graphNetwork['usdTargetRevenuePerEpoch']
minRequiredProofsPerEpoch = graphNetwork['minRequiredProofsPerEpoch']
dealsTotal = graphNetwork['dealsTotal']
proofsTotal = graphNetwork['proofsTotal']
offersTotal = graphNetwork['offersTotal']
providersTotal = graphNetwork['providersTotal']
effectorsTotal = graphNetwork['effectorsTotal']
commitmentCreatedCount = graphNetwork['capacityCommitmentsTotal']

FLT_PRICE.set(fltPrice)
SLASHING_RATE.set(slashingRate)
CORE_EPOCH_DURATION.set(coreEpochDuration)
CAPACITY_MAX_FAILED_RATIO.set(capacityMaxFailedRatio)
USD_TARGET_REVENUE_PER_EPOCH.set(usdTargetRevenuePerEpoch)
MIN_REQUIRED_PROOFS_PER_EPOCH.set(minRequiredProofsPerEpoch)
DEALS_TOTAL.set(dealsTotal)
PROOFS_TOTAL.set(proofsTotal)
OFFERS_TOTAL.set(offersTotal)
PROVIDERS_TOTAL.set(providersTotal)
EFFECTORS_TOTAL.set(effectorsTotal)
COMMITMENT_CREATED_COUNT.set(commitmentCreatedCount)

except Exception as e:
logger.error(f"Error collecting graph networks: {e}")
raise

def collect_metrics(graph_node, providers_to_monitor):
try:
get_latest_block(graph_node)
collect_graph_networks_metrics(graph_node)
if providers_to_monitor:
for provider_id in providers_to_monitor:
provider_name = get_provider_name(graph_node, provider_id)
Expand Down
15 changes: 14 additions & 1 deletion metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,17 @@

FLUENCE_SUBGRAPH_LATEST_BLOCK = Gauge('fluence_network_subgraph_latest_block','The latest block number seen by subgraph', registry=registry)

REWARD_BALANCE_FLT = Gauge('fluence_network_reward_balance', 'Amount of FLT designated to Capacity Rewards on Diamond (scaled to ether)', registry=registry)
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)
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)
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)
MIN_REQUIRED_PROOFS_PER_EPOCH = Gauge("fluence_network_min_required_proofs_per_epoch", "Minimum proofs per CU per epoch", registry=registry)
DEALS_TOTAL = Gauge("fluence_network_deals_total", "Total count of created deals", registry=registry)
PROOFS_TOTAL = Gauge("fluence_network_proofs_total", "Total count of submitted proofs", registry=registry)
OFFERS_TOTAL = Gauge("fluence_network_offers_total", "Total count of created offers", registry=registry)
PROVIDERS_TOTAL = Gauge("fluence_network_providers_total", "Total count of providers", registry=registry)
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)

0 comments on commit 1ab34bd

Please sign in to comment.