feat: label build identity in metrics

This commit is contained in:
2026-09-20 18:32:05 +08:00
parent 552fd22704
commit 6788d89275
4 changed files with 12 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
package observability
import "runtime"
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"}
@@ -16,6 +16,7 @@ var eventTypes = []string{"task.accepted", "task.started", "task.succeeded", "ta
// 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},
@@ -29,7 +30,7 @@ func catalog() map[string]descriptor {
"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_go_goroutines": {gauge, "Current Go goroutine count", nil},
"orbit_build_info": {gauge, "Orbit Go runtime build information", map[string][]string{"go_version": {runtime.Version()}}},
"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",