feat: sample terminal business latency

This commit is contained in:
2026-09-19 16:30:20 +08:00
parent 8ce9f4e1fa
commit 5a49dd5644
14 changed files with 139 additions and 21 deletions

View File

@@ -34,6 +34,9 @@ func TestIntegrationOperationalSnapshot(t *testing.T) {
{"pulse_tasks", "ix_task_observe_state_available"},
{"orbit_deliveries", "ix_delivery_observe_state_available"},
{"weave_instances", "ix_workflow_observe_state_updated"},
{"orbit_events", "ix_event_observe_type_occurred"},
{"pulse_tasks", "ix_task_observe_terminal_completed"},
{"weave_instances", "ix_workflow_observe_terminal_completed"},
} {
var n int
if err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM information_schema.statistics WHERE table_schema=DATABASE() AND table_name=? AND index_name=?`, want.table, want.index).Scan(&n); err != nil {
@@ -52,7 +55,7 @@ func TestIntegrationOperationalSnapshot(t *testing.T) {
}
f := newExecutionFixture(t, ctx, db)
f.submit(2)
task := f.submit(2)
snapshot, err := ReadOperationalSnapshot(ctx, db)
if err != nil {
t.Fatal(err)
@@ -77,6 +80,14 @@ func TestIntegrationOperationalSnapshot(t *testing.T) {
if _, ok := snapshot.WorkflowStates["RUNNING"]; !ok {
t.Fatal("missing running workflow state")
}
f.exec("UPDATE pulse_tasks SET state='SUCCEEDED', completed_at=UTC_TIMESTAMP(6), updated_at=UTC_TIMESTAMP(6), revision=revision+1 WHERE namespace_id=? AND id=?", f.resources.NamespaceID, task.ID)
completed, err := ReadOperationalSnapshot(ctx, db)
if err != nil {
t.Fatal(err)
}
if completed.TaskTerminalLatencySeconds < 0 || completed.TaskTerminalLatencyMaxSeconds < 0 {
t.Fatalf("negative terminal latency: %#v", completed)
}
cancelled, cancelNow := context.WithCancel(ctx)
cancelNow()