Superuser route to flush the metrics collector now
POST /observability/flush handles what the collector has queued and writes it, so the soak harness no longer sleeps FLUSH_INTERVAL_S before clearing its own rows.
This commit is contained in:
+13
-6
@@ -36,7 +36,6 @@ from typing import Any
|
||||
import httpx
|
||||
|
||||
from fluksio.core.config import settings
|
||||
from fluksio.flow.metrics import FLUSH_INTERVAL_S
|
||||
|
||||
log = logging.getLogger("soak")
|
||||
|
||||
@@ -374,6 +373,14 @@ def create_flow(
|
||||
log.info("created flow '%s'", name)
|
||||
|
||||
|
||||
def flush_metrics(client: httpx.Client) -> None:
|
||||
"""Have the metrics collector write what it holds now."""
|
||||
try:
|
||||
client.post("/api/v1/observability/flush").raise_for_status()
|
||||
except httpx.HTTPError as exc:
|
||||
log.error("could not flush the metrics collector: %s", exc)
|
||||
|
||||
|
||||
def delete_flows(client: httpx.Client) -> None:
|
||||
for name in FLOWS:
|
||||
try:
|
||||
@@ -887,11 +894,11 @@ def cleanup(client: httpx.Client | None) -> None:
|
||||
delete_flows(client)
|
||||
|
||||
clear_redis()
|
||||
# Deleting a flow publishes an audit event of its own, and the metrics
|
||||
# collector buffers what it hears for up to FLUSH_INTERVAL_S before writing
|
||||
# it. Clearing the tables any sooner races that flush and leaves the rows
|
||||
# this very cleanup caused.
|
||||
time.sleep(FLUSH_INTERVAL_S + 5.0)
|
||||
# Deleting a flow publishes an audit event of its own, which the metrics
|
||||
# collector holds until its next flush. Clearing the tables before it is
|
||||
# written would leave the rows this very cleanup caused.
|
||||
if client is not None:
|
||||
flush_metrics(client)
|
||||
clear_observability()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user