Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: formatting typo, some mypy errors #18

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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