lablink_allocator_service.routes.metrics¶
lablink_allocator_service.routes.metrics
¶
Session metrics: client push, operator summary, and full export.
_session_metrics_view_model is shared by the HTML page and the JSON
summary endpoint so the two cannot disagree on monitoring-enabled state,
subject-software label, or summary numbers.
Attributes¶
bp = Blueprint('metrics', __name__)
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Functions:¶
admin_session_metrics()
¶
Render the cohort summary + per-VM table for Tier 1 monitoring.
Source code in packages/allocator/src/lablink_allocator_service/routes/metrics.py
export_metrics()
¶
Export metrics.
Per-VM metrics as CSV or JSON (controlled by ?format=). Backs
lablink export-metrics --client.
Source code in packages/allocator/src/lablink_allocator_service/routes/metrics.py
get_session_metrics_summary_json()
¶
Get the cohort summary.
Returns the aggregate view model — participation funnel plus cohort
totals. Both the admin Session Metrics page and lablink stats
render this same payload, so the two can never disagree.
Source code in packages/allocator/src/lablink_allocator_service/routes/metrics.py
post_session_metrics(hostname)
¶
Report session metrics.
The client's monitoring sampler posts its accumulated per-session counters (time-in-software, GPU activity, training progress).
The 200 response echoes session_started_at — the VM's
authoritative assignment time (ISO-8601, null while the seat is
free) — which the client writes to its session anchor, healing an
anchor lost to a container restart mid-session.
Error Response:
- Code:
400 Bad Requestifcountersis missing. - Code:
404 Not Foundif the VM does not exist. - Code:
409 Conflictif the session's row is already sealed.