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:
@@ -19,12 +19,17 @@ from sqlalchemy import select as sa_select
|
||||
from sqlmodel import col, select
|
||||
|
||||
from fluksio import __version__
|
||||
from fluksio.api.deps import FlowControllerDep, SessionDep, get_current_user
|
||||
from fluksio.api.deps import (
|
||||
FlowControllerDep,
|
||||
SessionDep,
|
||||
get_current_active_superuser,
|
||||
get_current_user,
|
||||
)
|
||||
from fluksio.api.routes.runs import elapsed_ms
|
||||
from fluksio.core.config import settings
|
||||
from fluksio.flow.controller import NodeStatus
|
||||
from fluksio.flow.pipeline import ADVISORY_ISSUES
|
||||
from fluksio.models import EngineEvent, FlowRun, MetricBucket
|
||||
from fluksio.models import EngineEvent, FlowRun, Message, MetricBucket
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/observability",
|
||||
@@ -508,3 +513,18 @@ async def read_dead_letters(
|
||||
if controller.execution is None:
|
||||
return []
|
||||
return await run_in_threadpool(controller.execution.queue.dead_letters, limit)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/flush",
|
||||
response_model=Message,
|
||||
dependencies=[Depends(get_current_active_superuser)],
|
||||
)
|
||||
async def flush_metrics(request: Request) -> Any:
|
||||
"""Write what the metrics collector holds now, not at its next interval.
|
||||
|
||||
For tooling that reads or clears these tables right after causing events,
|
||||
such as the soak harness clearing its own rows.
|
||||
"""
|
||||
await request.app.state.metrics_collector.flush_now()
|
||||
return Message(message="Metrics flushed")
|
||||
|
||||
Reference in New Issue
Block a user