Skip to content

Commit

Permalink
fix: formatting typo, some mypy errors (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
folex authored Sep 28, 2024
1 parent c433b05 commit a047c31
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
9 changes: 4 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import logging
import sys
from prometheus_client import generate_latest, CollectorRegistry
from flask import Flask, Response
from prometheus_client import generate_latest
from flask import Flask, Response, cli

import config_loader
import metrics
Expand All @@ -16,7 +16,6 @@

# Disable Flask's default logging
logging.getLogger("werkzeug").disabled = True
cli = sys.modules['flask.cli']
cli.show_server_banner = lambda *x: None

app = Flask(__name__)
Expand All @@ -30,7 +29,7 @@ def root():


@app.route('/metrics')
def metrics():
def metrics_endpoint():
try:
nm.collect_metrics(rpc, addresses_to_monitor, diamond_address)
gm.collect_metrics(graph_node, providers_to_monitor)
Expand All @@ -50,7 +49,7 @@ def metrics():

rpc_url = config.rpc_url
graph_node_url = config.graph_node_url
port = int(os.getenv("PORT", config.port))
port = int(os.getenv("PORT", str(config.port)))

addresses_to_monitor = config.addresses
providers_to_monitor = config.providers
Expand Down
4 changes: 2 additions & 2 deletions config_loader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import yaml
from pydantic import BaseModel, ValidationError, constr, conlist, condecimal
from typing import List, Optional
from typing import Optional
import pathlib
import logging

Expand All @@ -16,7 +16,7 @@ class AddressEntry(BaseModel):
class TransactionConfig(BaseModel):
enabled: bool
private_key_path: Optional[str] = None
interval: Optional[str] = "60s"
interval: str = "60s"


class ConfigSchema(BaseModel):
Expand Down
6 changes: 2 additions & 4 deletions network_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ def collect_balances(rpc: Web3, addresses_to_monitor: list[AddressEntry]):

FLUENCE_BALANCE.labels(
address=address, name=name).set(balance_eth)
logger.debug(f"Address {address} ({name}) balance is: {
balance_eth} FLT")
logger.debug(f"Address {address} ({name}) balance is: {balance_eth} FLT")
FLUENCE_BALANCE_MINIMUM.labels(
address=address, name=name).set(minimum_balance)

Expand All @@ -129,8 +128,7 @@ def collect_reward_balance(rpc: Web3, diamond_address: str):
reward_balance = diamond.functions.getRewardBalance().call()
reward_balance_eth = rpc.from_wei(reward_balance, 'ether')
REWARD_BALANCE_FLT.set(reward_balance_eth)
logger.debug(f"Diamond {diamond_address} reward balance is {
reward_balance_eth} FLT")
logger.debug(f"Diamond {diamond_address} reward balance is {reward_balance_eth} FLT")


def collect_metrics(
Expand Down

0 comments on commit a047c31

Please sign in to comment.