feat: sample recent business events

This commit is contained in:
2026-09-18 21:12:05 +08:00
parent 5284206731
commit 8ce9f4e1fa
14 changed files with 68 additions and 18 deletions

View File

@@ -23,6 +23,8 @@ type BusinessSnapshot struct {
WorkflowOldestAgeSeconds float64
// Truncated 是否至少有一类状态达到采样上限。
Truncated bool
// RecentEvents 固定事件类别在最近窗口内的有界数量。
RecentEvents map[string]uint64
}
// RecordBusinessSnapshot records one bounded database sample. A failed sample
@@ -53,6 +55,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 _, eventType := range eventTypes {
r.SetGauge("orbit_business_events_recent", float64(snapshot.RecentEvents[eventType]), Labels{"event": eventType})
}
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)