package observability import "git.yuntuo.hk/k2safe/orbit/internal/buildinfo" var methods = []string{"GET", "POST", "PATCH", "PUT", "DELETE", "HEAD", "OPTIONS", "OTHER"} var routes = []string{"health_live", "health_ready", "worker_connect", "event_connect", "tasks", "queues", "workflows", "workflow_definitions", "schedules", "subscriptions", "application_resources", "other"} var statusClasses = []string{"1xx", "2xx", "3xx", "4xx", "5xx", "other"} var components = []string{"workflow", "schedule", "execution_recovery"} var taskStates = []string{"WAITING", "LEASED", "RUNNING", "NEEDS_REVIEW", "SUCCEEDED", "FAILED", "CANCELLED"} var deliveryStates = []string{"PENDING", "LEASED", "ACKED", "EXPIRED"} var workflowStates = []string{"RUNNING", "WAITING", "CANCELLING", "NEEDS_REVIEW", "SUCCEEDED", "FAILED", "CANCELLED"} var inboxStates = []string{"PENDING", "LEASED", "PROCESSED", "QUARANTINED"} var eventTypes = []string{"task.accepted", "task.started", "task.succeeded", "task.failed", "task.cancelled", "task.needs_review", "task.requeued", "workflow.started", "workflow.advanced", "workflow.recovered", "workflow.blocked", "workflow.stopped"} // Every exported family is declared here, including each allowed label value. // Adding a metric therefore requires a code review; no user identifier is valid. func catalog() map[string]descriptor { httpLabels := map[string][]string{"method": methods, "route": routes, "status_class": statusClasses} build := buildinfo.Current() c := map[string]descriptor{ "orbit_http_requests_total": {counter, "Completed HTTP responses, including successful upgrade handshakes", httpLabels}, "orbit_http_request_duration_seconds": {histogram, "HTTP response or upgrade handshake duration in seconds", httpLabels}, "orbit_http_requests_in_flight": {gauge, "HTTP handlers before completion or successful hijack", nil}, "orbit_http_panics_total": {counter, "HTTP handlers which panicked, before or after upgrade", nil}, "orbit_websocket_connections": {gauge, "Upgraded WebSocket handlers currently active", map[string][]string{"route": {"worker_connect", "event_connect"}}}, "orbit_websocket_connections_total": {counter, "Successful WebSocket upgrades", map[string][]string{"route": {"worker_connect", "event_connect"}}}, "orbit_runtime_batch_total": {counter, "Completed background batches by outcome", map[string][]string{"component": components, "outcome": {"success", "error", "cancelled"}}}, "orbit_runtime_batch_duration_seconds": {histogram, "Background batch duration in seconds", map[string][]string{"component": components}}, "orbit_runtime_batch_last_success_timestamp_seconds": {gauge, "Unix time of last successful background batch, zero before first success", map[string][]string{"component": components}}, "orbit_process_start_time_seconds": {gauge, "Unix time when the Orbit metrics registry was started", nil}, "orbit_process_uptime_seconds": {gauge, "Monotonic elapsed time since metrics registry startup", nil}, "orbit_process_draining": {gauge, "Whether this process is draining for graceful shutdown", nil}, "orbit_go_goroutines": {gauge, "Current Go goroutine count", nil}, "orbit_build_info": {gauge, "Orbit build and protocol information", map[string][]string{"go_version": {build.GoVersion}, "version": {build.Version}, "revision": {build.Revision}}}, } for name, help := range map[string]string{ "open": "Open MySQL connections", "in_use": "MySQL connections currently in use", "idle": "Idle MySQL connections", "max_open": "Configured maximum open MySQL connections", } { c["orbit_db_connections_"+name] = descriptor{gauge, help, nil} } c["orbit_db_wait_count_total"] = descriptor{counter, "Cumulative waits for a MySQL connection", nil} c["orbit_db_wait_duration_seconds_total"] = descriptor{counter, "Cumulative seconds waiting for a MySQL connection", nil} c["orbit_db_transaction_retries_total"] = descriptor{counter, "Cumulative pre-commit MySQL transaction retries", nil} c["orbit_db_transaction_retry_exhausted_total"] = descriptor{counter, "Cumulative pre-commit MySQL transaction retry exhaustion", nil} c["orbit_pulse_tasks_state"] = descriptor{gauge, "Bounded count of Pulse tasks by durable state", map[string][]string{"state": taskStates}} c["orbit_pulse_tasks_oldest_age_seconds"] = descriptor{gauge, "Age of the oldest sampled unfinished Pulse task", nil} c["orbit_result_deliveries_state"] = descriptor{gauge, "Bounded count of result deliveries by durable state", map[string][]string{"state": deliveryStates}} c["orbit_result_delivery_oldest_age_seconds"] = descriptor{gauge, "Age of the oldest sampled pending result delivery", nil} 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_weave_inbox_state"] = descriptor{gauge, "Bounded count of Weave internal inbox records by durable state", map[string][]string{"state": inboxStates}} c["orbit_weave_inbox_oldest_age_seconds"] = descriptor{gauge, "Age of the oldest sampled pending Weave inbox record", 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_pulse_task_accept_to_start_latency_seconds"] = descriptor{gauge, "Average sampled Pulse task accepted-to-start latency in seconds", nil} c["orbit_pulse_task_accept_to_start_latency_max_seconds"] = descriptor{gauge, "Maximum sampled Pulse task accepted-to-start latency in seconds", nil} c["orbit_pulse_task_accept_to_terminal_latency_seconds"] = descriptor{gauge, "Average sampled Pulse task accepted-to-terminal latency in seconds", nil} c["orbit_pulse_task_accept_to_terminal_latency_max_seconds"] = descriptor{gauge, "Maximum sampled Pulse task accepted-to-terminal latency in seconds", nil} c["orbit_weave_workflow_start_to_terminal_latency_seconds"] = descriptor{gauge, "Average sampled Weave workflow started-to-terminal latency in seconds", nil} c["orbit_weave_workflow_start_to_terminal_latency_max_seconds"] = descriptor{gauge, "Maximum sampled Weave workflow started-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} c["orbit_business_snapshot_truncated"] = descriptor{gauge, "Whether a bounded business-state sample hit its per-state cap", nil} c["orbit_runtime_tick_interval_seconds"] = descriptor{gauge, "Configured background controller tick interval in seconds", map[string][]string{"component": components}} c["orbit_runtime_batch_limit"] = descriptor{gauge, "Configured maximum candidates per background batch", nil} c["orbit_shutdown_timeout_seconds"] = descriptor{gauge, "Configured graceful drain and shutdown window in seconds", nil} c["orbit_worker_connection_limit"] = descriptor{gauge, "Configured maximum Worker WebSocket connections on this node", nil} c["orbit_event_connection_limit"] = descriptor{gauge, "Configured maximum Event WebSocket connections on this node", nil} c["orbit_dispatch_workers"] = descriptor{gauge, "Configured database claim workers per WebSocket hub", nil} c["orbit_dispatch_capacity"] = descriptor{gauge, "Configured bounded in-memory claim queue per WebSocket hub", nil} return c }