feat: sample terminal business latency
This commit is contained in:
@@ -25,6 +25,14 @@ type BusinessSnapshot struct {
|
||||
Truncated bool
|
||||
// RecentEvents 固定事件类别在最近窗口内的有界数量。
|
||||
RecentEvents map[string]uint64
|
||||
// TaskTerminalLatencySeconds 最近窗口终态任务创建到完成的平均耗时样本。
|
||||
TaskTerminalLatencySeconds float64
|
||||
// TaskTerminalLatencyMaxSeconds 最近窗口终态任务样本最大耗时。
|
||||
TaskTerminalLatencyMaxSeconds float64
|
||||
// WorkflowTerminalLatencySeconds 最近窗口终态流程创建到完成的平均耗时样本。
|
||||
WorkflowTerminalLatencySeconds float64
|
||||
// WorkflowTerminalLatencyMaxSeconds 最近窗口终态流程样本最大耗时。
|
||||
WorkflowTerminalLatencyMaxSeconds float64
|
||||
}
|
||||
|
||||
// RecordBusinessSnapshot records one bounded database sample. A failed sample
|
||||
@@ -58,6 +66,10 @@ func (r *Registry) RecordBusinessSnapshot(snapshot BusinessSnapshot, started tim
|
||||
for _, eventType := range eventTypes {
|
||||
r.SetGauge("orbit_business_events_recent", float64(snapshot.RecentEvents[eventType]), Labels{"event": eventType})
|
||||
}
|
||||
r.SetGauge("orbit_pulse_task_terminal_latency_seconds", snapshot.TaskTerminalLatencySeconds, nil)
|
||||
r.SetGauge("orbit_pulse_task_terminal_latency_max_seconds", snapshot.TaskTerminalLatencyMaxSeconds, nil)
|
||||
r.SetGauge("orbit_weave_workflow_terminal_latency_seconds", snapshot.WorkflowTerminalLatencySeconds, nil)
|
||||
r.SetGauge("orbit_weave_workflow_terminal_latency_max_seconds", snapshot.WorkflowTerminalLatencyMaxSeconds, nil)
|
||||
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)
|
||||
|
||||
@@ -44,6 +44,10 @@ func catalog() map[string]descriptor {
|
||||
c["orbit_weave_workflows_state"] = descriptor{gauge, "Bounded count of Weave instances by durable state", map[string][]string{"state": workflowStates}}
|
||||
c["orbit_weave_workflow_oldest_age_seconds"] = descriptor{gauge, "Age of the oldest sampled unfinished Weave instance", nil}
|
||||
c["orbit_business_events_recent"] = descriptor{gauge, "Bounded count of fixed event categories in the recent window", map[string][]string{"event": eventTypes}}
|
||||
c["orbit_pulse_task_terminal_latency_seconds"] = descriptor{gauge, "Average sampled Pulse task create-to-terminal latency in seconds", nil}
|
||||
c["orbit_pulse_task_terminal_latency_max_seconds"] = descriptor{gauge, "Maximum sampled Pulse task create-to-terminal latency in seconds", nil}
|
||||
c["orbit_weave_workflow_terminal_latency_seconds"] = descriptor{gauge, "Average sampled Weave workflow create-to-terminal latency in seconds", nil}
|
||||
c["orbit_weave_workflow_terminal_latency_max_seconds"] = descriptor{gauge, "Maximum sampled Weave workflow create-to-terminal latency in seconds", nil}
|
||||
c["orbit_business_snapshot_total"] = descriptor{counter, "Completed bounded business-state snapshots by outcome", map[string][]string{"outcome": {"success", "error", "timeout"}}}
|
||||
c["orbit_business_snapshot_duration_seconds"] = descriptor{histogram, "Bounded business-state snapshot duration in seconds", nil}
|
||||
c["orbit_business_snapshot_last_success_timestamp_seconds"] = descriptor{gauge, "Unix time of the last successful bounded business-state snapshot", nil}
|
||||
|
||||
@@ -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`,
|
||||
|
||||
Reference in New Issue
Block a user