Archived
Refactor UI assets and harden quality checks
This commit is contained in:
1 parent
23ab466c52
commit
4ecc8eb874
62 files changed
+3314
-3206
No files matched your search
+30
-13
@@ -5,6 +5,29 @@ from datetime import UTC, datetime
|
||||
from .base import StoreConnectionMixin
|
||||
|
||||
|
||||
def _update_metric_increments(
|
||||
latency_ms: float,
|
||||
*,
|
||||
is_success: bool,
|
||||
is_dns_failure: bool,
|
||||
is_reconcile_failure: bool,
|
||||
is_bad_ip: bool,
|
||||
) -> dict[str, float]:
|
||||
increments: dict[str, float] = {
|
||||
"update_requests_total": 1,
|
||||
"update_latency_ms_total": latency_ms,
|
||||
"update_latency_samples_total": 1,
|
||||
}
|
||||
optional_increments = {
|
||||
"update_success_total": is_success,
|
||||
"dns_failures_total": is_dns_failure,
|
||||
"dns_reconcile_failures_total": is_reconcile_failure,
|
||||
"bad_ip_total": is_bad_ip,
|
||||
}
|
||||
increments.update({name: 1 for name, enabled in optional_increments.items() if enabled})
|
||||
return increments
|
||||
|
||||
|
||||
class MetricsMixin(StoreConnectionMixin):
|
||||
def increment_metric(self, name: str, amount: float = 1.0) -> None:
|
||||
now = datetime.now(UTC).isoformat()
|
||||
@@ -48,19 +71,13 @@ class MetricsMixin(StoreConnectionMixin):
|
||||
is_reconcile_failure: bool = False,
|
||||
is_bad_ip: bool = False,
|
||||
) -> None:
|
||||
increments = {
|
||||
"update_requests_total": 1,
|
||||
"update_latency_ms_total": latency_ms,
|
||||
"update_latency_samples_total": 1,
|
||||
}
|
||||
if is_success:
|
||||
increments["update_success_total"] = 1
|
||||
if is_dns_failure:
|
||||
increments["dns_failures_total"] = 1
|
||||
if is_reconcile_failure:
|
||||
increments["dns_reconcile_failures_total"] = 1
|
||||
if is_bad_ip:
|
||||
increments["bad_ip_total"] = 1
|
||||
increments = _update_metric_increments(
|
||||
latency_ms,
|
||||
is_success=is_success,
|
||||
is_dns_failure=is_dns_failure,
|
||||
is_reconcile_failure=is_reconcile_failure,
|
||||
is_bad_ip=is_bad_ip,
|
||||
)
|
||||
|
||||
now = datetime.now(UTC).isoformat()
|
||||
with self.connect() as conn:
|
||||
|
||||
Reference in new issue
Block a user