feat(system): instrument worker pipeline stages
This commit is contained in:
@@ -394,3 +394,31 @@ def test_runtime_telemetry_captures_bounded_queue_snapshots() -> None:
|
||||
row = json.loads(stream.getvalue())
|
||||
assert row["schema_version"] == "missioncore.worker-runtime-telemetry/v1"
|
||||
assert row["queues"]["detector"]["maximum_depth"] == 1
|
||||
|
||||
|
||||
def test_stage_execution_telemetry_measures_named_spans_without_process_claims() -> None:
|
||||
module = _module()
|
||||
telemetry = module._StageExecutionTelemetry(("detector", "tracking"))
|
||||
|
||||
with telemetry.measure("detector", frame_index=42):
|
||||
pass
|
||||
with telemetry.measure("tracking", frame_index=42):
|
||||
pass
|
||||
|
||||
snapshot = telemetry.snapshot()
|
||||
assert snapshot["current_stage"] is None
|
||||
assert snapshot["active_stages"] == []
|
||||
assert snapshot["active_frame_index"] == 42
|
||||
assert snapshot["stages"]["detector"]["activations"] == 1
|
||||
assert snapshot["stages"]["tracking"]["activations"] == 1
|
||||
assert snapshot["stages"]["detector"]["elapsed_seconds"] >= 0
|
||||
assert snapshot["stages"]["tracking"]["elapsed_seconds"] >= 0
|
||||
assert sum(
|
||||
stage["share_percent"] for stage in snapshot["stages"].values()
|
||||
) == pytest.approx(100)
|
||||
|
||||
with (
|
||||
pytest.raises(RuntimeError, match="unknown pipeline stage"),
|
||||
telemetry.measure("unregistered"),
|
||||
):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user