mirror of
https://github.com/logos-storage/bittorrent-benchmarks.git
synced 2026-04-07 10:53:07 +00:00
feat: enable metrics and log blocks served per node after each experiment
Signed-off-by: Chrysostomos Nanakos <chris@include.gr>
This commit is contained in:
parent
2f4e941c25
commit
ff3ff04259
@ -112,6 +112,19 @@ class CodexNode(Node[Cid, CodexMeta], ExperimentComponent):
|
||||
|
||||
return response.iter_content(chunk_size=chunk_size)
|
||||
|
||||
def blocks_sent(self, metrics_port: int = 8008) -> int:
|
||||
"""Query the Prometheus metrics endpoint for blocks sent count."""
|
||||
try:
|
||||
metrics_url = self.codex_api_url._replace(port=metrics_port, path="/metrics")
|
||||
response = requests.get(str(metrics_url), timeout=5)
|
||||
response.raise_for_status()
|
||||
for line in response.text.splitlines():
|
||||
if line.startswith("storage_block_exchange_blocks_sent_total"):
|
||||
return int(float(line.split()[1]))
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
|
||||
def wipe_all_datasets(self):
|
||||
for dataset in list(self.hosted_datasets):
|
||||
self.remove(dataset)
|
||||
|
||||
@ -15,7 +15,7 @@ from benchmarks.core.network import (
|
||||
Node,
|
||||
DownloadHandle,
|
||||
)
|
||||
from benchmarks.logging.logging import RequestEvent, EventBoundary
|
||||
from benchmarks.logging.logging import RequestEvent, EventBoundary, BlocksServedMetric
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -119,6 +119,16 @@ class StaticDisseminationExperiment(
|
||||
]
|
||||
)
|
||||
|
||||
with experiment_stage(self, "blocks_served"):
|
||||
for i, node in enumerate(self.nodes):
|
||||
if hasattr(node, "blocks_sent"):
|
||||
logger.info(
|
||||
BlocksServedMetric(
|
||||
node=node.name,
|
||||
value=node.blocks_sent(),
|
||||
)
|
||||
)
|
||||
|
||||
with experiment_stage(self, "log_cooldown"):
|
||||
# FIXME this is a hack to ensure that nodes get a chance to log their data before we
|
||||
# run the teardown hook and remove the torrents.
|
||||
|
||||
@ -249,6 +249,10 @@ class DownloadMetric(Metric):
|
||||
dataset_name: str
|
||||
|
||||
|
||||
class BlocksServedMetric(Metric):
|
||||
name: str = "blocks_served"
|
||||
|
||||
|
||||
class EventBoundary(Enum):
|
||||
start = "start"
|
||||
end = "end"
|
||||
@ -279,6 +283,7 @@ def basic_log_parser() -> LogParser:
|
||||
parser.register(NodeEvent)
|
||||
parser.register(Metric)
|
||||
parser.register(DownloadMetric)
|
||||
parser.register(BlocksServedMetric)
|
||||
parser.register(RequestEvent)
|
||||
parser.register(ExperimentStatus)
|
||||
parser.register(ExperimentStage)
|
||||
|
||||
@ -65,6 +65,12 @@ spec:
|
||||
fieldPath: metadata.name
|
||||
- name: STORAGE_NAT
|
||||
value: "none"
|
||||
- name: STORAGE_METRICS
|
||||
value: "true"
|
||||
- name: STORAGE_METRICS_ADDRESS
|
||||
value: "0.0.0.0"
|
||||
- name: STORAGE_METRICS_PORT
|
||||
value: "8008"
|
||||
- name: STORAGE_BLOCK_TTL
|
||||
value: {{ .Values.experiment.blockTTL | quote }}
|
||||
- name: STORAGE_BLOCK_MI
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user