Home charts execution time per node type on a log scale, from a /observability/node-types rollup

This commit is contained in:
2026-10-15 16:57:07 +02:00
parent fa8b178866
commit 56fa34c2c9
9 changed files with 360 additions and 3 deletions
@@ -512,3 +512,59 @@ def test_a_superuser_can_flush_the_collector_now(
)
).all()
assert len(written) == 1
def test_execution_time_is_summed_per_node_type(
client: TestClient, superuser_token_headers: dict[str, str], db: Session
) -> None:
from fluksio.flow.schemas import FlowDef, NodeDef
flow = "node_type_test"
controller = client.app.state.flow_controller
before = controller.store.read_all
controller.store.read_all = lambda: [
FlowDef(
name=flow,
nodes=[
NodeDef(id="a", type="python"),
NodeDef(id="b", type="python"),
NodeDef(id="tick", type="inject"),
],
)
]
now = datetime.now(UTC).replace(second=0, microsecond=0)
for node, executions, total, peak in (
("a", 2, 30.0, 20.0),
("b", 2, 10.0, 6.0),
("tick", 4, 0.4, 0.2),
# Deleted since it ran: nothing to count it under.
("gone", 1, 500.0, 500.0),
):
db.add(
MetricBucket(
flow=flow,
node=f"{flow}.{node}",
bucket=now - timedelta(minutes=2),
executions=executions,
duration_sum_ms=total,
duration_max_ms=peak,
)
)
db.commit()
try:
rows = client.get(
f"{PREFIX}/node-types", headers=superuser_token_headers
).json()
finally:
controller.store.read_all = before
# Slowest first.
assert [row["type"] for row in rows] == ["python", "inject"]
assert rows[0] == {
"type": "python",
"nodes": 2,
"executions": 4,
"avg_ms": 10.0,
"max_ms": 20.0,
}
assert rows[1]["avg_ms"] == 0.1