GTFS file size metric
All checks were successful
Amarillo/amarillo-gitea/amarillo-metrics/pipeline/head This commit looks good

This commit is contained in:
Csaba 2024-02-16 14:56:42 +01:00
parent ff1776e015
commit 3837f968aa
2 changed files with 21 additions and 1 deletions

View file

@ -30,6 +30,24 @@ def amarillo_trips_number_total() -> Callable[[Info], None]:
return instrumentation return instrumentation
def amarillo_gtfs_file_size() -> Callable[[Info], None]:
METRIC = Gauge("amarillo_gtfs_file_size_MB", "Total file size of GTFS data.")
def instrumentation(info: Info) -> None:
total_size = sum(os.path.getsize(os.path.join(path, file)) for path, dirnames, files in os.walk("./data/gtfs") for file in files)
METRIC.set(total_size/1_000_000)
return instrumentation
def amarillo_grfs_file_size() -> Callable[[Info], None]:
METRIC = Gauge("amarillo_grfs_file_size_MB", "Total file size of GRFS data.")
def instrumentation(info: Info) -> None:
total_size = sum(os.path.getsize(os.path.join(path, file)) for path, dirnames, files in os.walk("./data/grfs") for file in files)
METRIC.set(total_size/1_000_000)
return instrumentation
router = APIRouter( router = APIRouter(
prefix="/metrics", prefix="/metrics",
@ -59,6 +77,8 @@ def setup(app: FastAPI):
instrumentator = Instrumentator().instrument(app) instrumentator = Instrumentator().instrument(app)
instrumentator.add(pfi_metrics.default()) instrumentator.add(pfi_metrics.default())
instrumentator.add(amarillo_trips_number_total()) instrumentator.add(amarillo_trips_number_total())
instrumentator.add(amarillo_gtfs_file_size())
instrumentator.add(amarillo_grfs_file_size())
instrumentator.instrument(app) instrumentator.instrument(app)

View file

@ -1,6 +1,6 @@
[project] [project]
name = "amarillo-metrics" name = "amarillo-metrics"
version = "0.0.4" version = "0.0.5"
description = "Prometheus metrics for Amarillo" description = "Prometheus metrics for Amarillo"
readme = "README.md" readme = "README.md"
license = {file = "LICENSE"} license = {file = "LICENSE"}