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

@@ -117,14 +117,16 @@ func TestBusinessSnapshotKeepsLastGoodStateOnFailure(t *testing.T) {
r := NewRegistry()
started := time.Now().Add(-25 * time.Millisecond)
r.RecordBusinessSnapshot(BusinessSnapshot{
TaskStates: map[string]uint64{"WAITING": 3},
TaskOldestAgeSeconds: 12.5,
DeliveryStates: map[string]uint64{"PENDING": 2},
DeliveryOldestAgeSeconds: 8.25,
WorkflowStates: map[string]uint64{"RUNNING": 1},
WorkflowOldestAgeSeconds: 4.75,
RecentEvents: map[string]uint64{"task.accepted": 5},
Truncated: true,
TaskStates: map[string]uint64{"WAITING": 3},
TaskOldestAgeSeconds: 12.5,
DeliveryStates: map[string]uint64{"PENDING": 2},
DeliveryOldestAgeSeconds: 8.25,
WorkflowStates: map[string]uint64{"RUNNING": 1},
WorkflowOldestAgeSeconds: 4.75,
RecentEvents: map[string]uint64{"task.accepted": 5},
TaskTerminalLatencySeconds: 2.5, TaskTerminalLatencyMaxSeconds: 7.5,
WorkflowTerminalLatencySeconds: 3.5, WorkflowTerminalLatencyMaxSeconds: 9.5,
Truncated: true,
}, started, nil)
first := r.Render()
for _, want := range []string{
@@ -132,6 +134,8 @@ func TestBusinessSnapshotKeepsLastGoodStateOnFailure(t *testing.T) {
`orbit_result_deliveries_state{state="PENDING"} 2`,
`orbit_weave_workflows_state{state="RUNNING"} 1`,
`orbit_business_events_recent{event="task.accepted"} 5`,
"orbit_pulse_task_terminal_latency_seconds 2.5",
"orbit_weave_workflow_terminal_latency_max_seconds 9.5",
"orbit_pulse_tasks_oldest_age_seconds 12.5",
"orbit_business_snapshot_truncated 1",
`orbit_business_snapshot_total{outcome="success"} 1`,