Spaces:
Sleeping
Sleeping
Download adsp/monitoring/metrics.py from thanhnv2323/humanize-text-python: direct link, hf CLI and curl.
- Browser
- Download file 655 Bytes
-
https://huggingface.co/spaces/thanhnv2323/humanize-text-python/resolve/main/adsp/monitoring/metrics.py
- Command line
-
hf download hf://spaces/thanhnv2323/humanize-text-python/adsp/monitoring/metrics.py
-
curl -L -o metrics.py https://huggingface.co/spaces/thanhnv2323/humanize-text-python/resolve/main/adsp/monitoring/metrics.py
655 Bytes
| """Collects runtime metrics for observability.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass, field | |
| from typing import Dict | |
| class MetricsCollector: | |
| """Stores counters/gauges as a quick placeholder.""" | |
| _metrics: Dict[str, float] = field(default_factory=dict) | |
| def incr(self, name: str, value: float = 1.0) -> None: | |
| self._metrics[name] = self._metrics.get(name, 0.0) + value | |
| def write(self, name: str, value: float = 1.0) -> float: | |
| self._metrics[name] = value | |
| return self._metrics.get(name) | |
| def read(self, name: str) -> float: | |
| return self._metrics.get(name, 0.0) | |