chore: initialize monorepo with project scaffolding, configs, and CI setup

This commit is contained in:
oib
2025-09-27 06:05:25 +02:00
commit fe29631a86
170 changed files with 13708 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
from __future__ import annotations
from dataclasses import dataclass
from threading import Lock
from typing import Dict
@dataclass
class MetricValue:
name: str
value: float
class MetricsRegistry:
def __init__(self) -> None:
self._counters: Dict[str, float] = {}
self._gauges: Dict[str, float] = {}
self._lock = Lock()
def increment(self, name: str, amount: float = 1.0) -> None:
with self._lock:
self._counters[name] = self._counters.get(name, 0.0) + amount
def set_gauge(self, name: str, value: float) -> None:
with self._lock:
self._gauges[name] = value
def render_prometheus(self) -> str:
with self._lock:
lines: list[str] = []
for name, value in sorted(self._counters.items()):
lines.append(f"# TYPE {name} counter")
lines.append(f"{name} {value}")
for name, value in sorted(self._gauges.items()):
lines.append(f"# TYPE {name} gauge")
lines.append(f"{name} {value}")
return "\n".join(lines) + "\n"
metrics_registry = MetricsRegistry()