feat: observe workflow inbox backlog

This commit is contained in:
2026-09-19 17:42:49 +08:00
parent da5874b17a
commit 0ac3f2f3f8
10 changed files with 46 additions and 8 deletions

View File

@@ -21,6 +21,10 @@ type BusinessSnapshot struct {
WorkflowStates map[string]uint64
// WorkflowOldestAgeSeconds 未终结流程中最早更新时间的年龄。
WorkflowOldestAgeSeconds float64
// InboxStates Weave 内部事件状态的有界计数。
InboxStates map[string]uint64
// InboxOldestAgeSeconds 待消费内部事件中最早可处理记录的年龄。
InboxOldestAgeSeconds float64
// Truncated 是否至少有一类状态达到采样上限。
Truncated bool
// RecentEvents 固定事件类别在最近窗口内的有界数量。
@@ -63,6 +67,9 @@ func (r *Registry) RecordBusinessSnapshot(snapshot BusinessSnapshot, started tim
for _, state := range workflowStates {
r.SetGauge("orbit_weave_workflows_state", float64(snapshot.WorkflowStates[state]), Labels{"state": state})
}
for _, state := range inboxStates {
r.SetGauge("orbit_weave_inbox_state", float64(snapshot.InboxStates[state]), Labels{"state": state})
}
for _, eventType := range eventTypes {
r.SetGauge("orbit_business_events_recent", float64(snapshot.RecentEvents[eventType]), Labels{"event": eventType})
}
@@ -73,6 +80,7 @@ func (r *Registry) RecordBusinessSnapshot(snapshot BusinessSnapshot, started tim
r.SetGauge("orbit_pulse_tasks_oldest_age_seconds", snapshot.TaskOldestAgeSeconds, nil)
r.SetGauge("orbit_result_delivery_oldest_age_seconds", snapshot.DeliveryOldestAgeSeconds, nil)
r.SetGauge("orbit_weave_workflow_oldest_age_seconds", snapshot.WorkflowOldestAgeSeconds, nil)
r.SetGauge("orbit_weave_inbox_oldest_age_seconds", snapshot.InboxOldestAgeSeconds, nil)
truncated := 0.0
if snapshot.Truncated {
truncated = 1