From a824e4c8c238c247fb584cdc0bd5a55c7ff2dad4 Mon Sep 17 00:00:00 2001 From: yusing Date: Sat, 24 Jan 2026 15:55:46 +0800 Subject: [PATCH] refactor(metrics): remove unused fields from RouteAggregate and update related documentation - Removed `display_name`, `is_docker`, and `is_excluded` fields from the `RouteAggregate` struct and corresponding Swagger documentation. - Updated references in the README and code to reflect the removal of these fields, ensuring consistency across the codebase. --- internal/api/v1/docs/swagger.json | 15 --------------- internal/api/v1/docs/swagger.yaml | 6 ------ internal/metrics/uptime/README.md | 10 ++-------- internal/metrics/uptime/uptime.go | 8 -------- 4 files changed, 2 insertions(+), 37 deletions(-) diff --git a/internal/api/v1/docs/swagger.json b/internal/api/v1/docs/swagger.json index 81994556..438af7d7 100644 --- a/internal/api/v1/docs/swagger.json +++ b/internal/api/v1/docs/swagger.json @@ -4746,11 +4746,6 @@ "x-nullable": false, "x-omitempty": false }, - "display_name": { - "type": "string", - "x-nullable": false, - "x-omitempty": false - }, "downtime": { "type": "number", "x-nullable": false, @@ -4761,16 +4756,6 @@ "x-nullable": false, "x-omitempty": false }, - "is_docker": { - "type": "boolean", - "x-nullable": false, - "x-omitempty": false - }, - "is_excluded": { - "type": "boolean", - "x-nullable": false, - "x-omitempty": false - }, "statuses": { "type": "array", "items": { diff --git a/internal/api/v1/docs/swagger.yaml b/internal/api/v1/docs/swagger.yaml index 0b1d0377..cb17023d 100644 --- a/internal/api/v1/docs/swagger.yaml +++ b/internal/api/v1/docs/swagger.yaml @@ -1154,16 +1154,10 @@ definitions: - napping - starting type: string - display_name: - type: string downtime: type: number idle: type: number - is_docker: - type: boolean - is_excluded: - type: boolean statuses: items: $ref: '#/definitions/RouteStatus' diff --git a/internal/metrics/uptime/README.md b/internal/metrics/uptime/README.md index 4c5b985c..8c748c14 100644 --- a/internal/metrics/uptime/README.md +++ b/internal/metrics/uptime/README.md @@ -55,13 +55,10 @@ Individual route status at a point in time. ```go type RouteAggregate struct { Alias string `json:"alias"` - DisplayName string `json:"display_name"` Uptime float32 `json:"uptime"` Downtime float32 `json:"downtime"` Idle float32 `json:"idle"` AvgLatency float32 `json:"avg_latency"` - IsDocker bool `json:"is_docker"` - IsExcluded bool `json:"is_excluded"` CurrentStatus types.HealthStatus `json:"current_status" swaggertype:"string" enums:"healthy,unhealthy,unknown,napping,starting"` Statuses []Status `json:"statuses"` } @@ -312,7 +309,7 @@ const ws = new WebSocket( ws.onmessage = (event) => { const data = JSON.parse(event.data); data.data.forEach((route) => { - console.log(`${route.display_name}: ${route.uptime * 100}% uptime`); + console.log(`${route.alias}: ${route.uptime * 100}% uptime`); }); }; ``` @@ -336,7 +333,7 @@ _, agg := uptime.aggregateStatuses(entries, url.Values{ for _, route := range agg { fmt.Printf("%s: %.1f%% uptime, %.1fms avg latency\n", - route.DisplayName, route.Uptime*100, route.AvgLatency) + route.Alias, route.Uptime*100, route.AvgLatency) } ``` @@ -365,13 +362,10 @@ for _, route := range agg { "data": [ { "alias": "api-server", - "display_name": "API Server", "uptime": 0.98, "downtime": 0.02, "idle": 0.0, "avg_latency": 45.5, - "is_docker": true, - "is_excluded": false, "current_status": "healthy", "statuses": [ { "status": "healthy", "latency": 45, "timestamp": 1704892800 } diff --git a/internal/metrics/uptime/uptime.go b/internal/metrics/uptime/uptime.go index 08051f61..c8fc7bf9 100644 --- a/internal/metrics/uptime/uptime.go +++ b/internal/metrics/uptime/uptime.go @@ -27,13 +27,10 @@ type ( RouteStatuses map[string][]Status // @name RouteStatuses RouteAggregate struct { Alias string `json:"alias"` - DisplayName string `json:"display_name"` Uptime float32 `json:"uptime"` Downtime float32 `json:"downtime"` Idle float32 `json:"idle"` AvgLatency float32 `json:"avg_latency"` - IsDocker bool `json:"is_docker"` - IsExcluded bool `json:"is_excluded"` CurrentStatus types.HealthStatus `json:"current_status" swaggertype:"string" enums:"healthy,unhealthy,unknown,napping,starting"` Statuses []Status `json:"statuses"` } // @name RouteUptimeAggregate @@ -129,11 +126,9 @@ func (rs RouteStatuses) aggregate(limit int, offset int) Aggregated { statuses := rs[alias] up, down, idle, latency := rs.calculateInfo(statuses) - displayName := alias status := types.StatusUnknown r, ok := routes.GetIncludeExcluded(alias) if ok { - displayName = r.DisplayName() mon := r.HealthMonitor() if mon != nil { status = mon.Status() @@ -142,15 +137,12 @@ func (rs RouteStatuses) aggregate(limit int, offset int) Aggregated { result[i] = RouteAggregate{ Alias: alias, - DisplayName: displayName, Uptime: up, Downtime: down, Idle: idle, AvgLatency: latency, CurrentStatus: status, Statuses: statuses, - IsDocker: r != nil && r.IsDocker(), - IsExcluded: r == nil || r.ShouldExclude(), } } return result