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.
This commit is contained in:
yusing
2026-01-24 15:55:46 +08:00
parent 62fb690417
commit a824e4c8c2
4 changed files with 2 additions and 37 deletions

View File

@@ -4746,11 +4746,6 @@
"x-nullable": false, "x-nullable": false,
"x-omitempty": false "x-omitempty": false
}, },
"display_name": {
"type": "string",
"x-nullable": false,
"x-omitempty": false
},
"downtime": { "downtime": {
"type": "number", "type": "number",
"x-nullable": false, "x-nullable": false,
@@ -4761,16 +4756,6 @@
"x-nullable": false, "x-nullable": false,
"x-omitempty": 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": { "statuses": {
"type": "array", "type": "array",
"items": { "items": {

View File

@@ -1154,16 +1154,10 @@ definitions:
- napping - napping
- starting - starting
type: string type: string
display_name:
type: string
downtime: downtime:
type: number type: number
idle: idle:
type: number type: number
is_docker:
type: boolean
is_excluded:
type: boolean
statuses: statuses:
items: items:
$ref: '#/definitions/RouteStatus' $ref: '#/definitions/RouteStatus'

View File

@@ -55,13 +55,10 @@ Individual route status at a point in time.
```go ```go
type RouteAggregate struct { type RouteAggregate struct {
Alias string `json:"alias"` Alias string `json:"alias"`
DisplayName string `json:"display_name"`
Uptime float32 `json:"uptime"` Uptime float32 `json:"uptime"`
Downtime float32 `json:"downtime"` Downtime float32 `json:"downtime"`
Idle float32 `json:"idle"` Idle float32 `json:"idle"`
AvgLatency float32 `json:"avg_latency"` 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"` CurrentStatus types.HealthStatus `json:"current_status" swaggertype:"string" enums:"healthy,unhealthy,unknown,napping,starting"`
Statuses []Status `json:"statuses"` Statuses []Status `json:"statuses"`
} }
@@ -312,7 +309,7 @@ const ws = new WebSocket(
ws.onmessage = (event) => { ws.onmessage = (event) => {
const data = JSON.parse(event.data); const data = JSON.parse(event.data);
data.data.forEach((route) => { 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 { for _, route := range agg {
fmt.Printf("%s: %.1f%% uptime, %.1fms avg latency\n", 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": [ "data": [
{ {
"alias": "api-server", "alias": "api-server",
"display_name": "API Server",
"uptime": 0.98, "uptime": 0.98,
"downtime": 0.02, "downtime": 0.02,
"idle": 0.0, "idle": 0.0,
"avg_latency": 45.5, "avg_latency": 45.5,
"is_docker": true,
"is_excluded": false,
"current_status": "healthy", "current_status": "healthy",
"statuses": [ "statuses": [
{ "status": "healthy", "latency": 45, "timestamp": 1704892800 } { "status": "healthy", "latency": 45, "timestamp": 1704892800 }

View File

@@ -27,13 +27,10 @@ type (
RouteStatuses map[string][]Status // @name RouteStatuses RouteStatuses map[string][]Status // @name RouteStatuses
RouteAggregate struct { RouteAggregate struct {
Alias string `json:"alias"` Alias string `json:"alias"`
DisplayName string `json:"display_name"`
Uptime float32 `json:"uptime"` Uptime float32 `json:"uptime"`
Downtime float32 `json:"downtime"` Downtime float32 `json:"downtime"`
Idle float32 `json:"idle"` Idle float32 `json:"idle"`
AvgLatency float32 `json:"avg_latency"` 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"` CurrentStatus types.HealthStatus `json:"current_status" swaggertype:"string" enums:"healthy,unhealthy,unknown,napping,starting"`
Statuses []Status `json:"statuses"` Statuses []Status `json:"statuses"`
} // @name RouteUptimeAggregate } // @name RouteUptimeAggregate
@@ -129,11 +126,9 @@ func (rs RouteStatuses) aggregate(limit int, offset int) Aggregated {
statuses := rs[alias] statuses := rs[alias]
up, down, idle, latency := rs.calculateInfo(statuses) up, down, idle, latency := rs.calculateInfo(statuses)
displayName := alias
status := types.StatusUnknown status := types.StatusUnknown
r, ok := routes.GetIncludeExcluded(alias) r, ok := routes.GetIncludeExcluded(alias)
if ok { if ok {
displayName = r.DisplayName()
mon := r.HealthMonitor() mon := r.HealthMonitor()
if mon != nil { if mon != nil {
status = mon.Status() status = mon.Status()
@@ -142,15 +137,12 @@ func (rs RouteStatuses) aggregate(limit int, offset int) Aggregated {
result[i] = RouteAggregate{ result[i] = RouteAggregate{
Alias: alias, Alias: alias,
DisplayName: displayName,
Uptime: up, Uptime: up,
Downtime: down, Downtime: down,
Idle: idle, Idle: idle,
AvgLatency: latency, AvgLatency: latency,
CurrentStatus: status, CurrentStatus: status,
Statuses: statuses, Statuses: statuses,
IsDocker: r != nil && r.IsDocker(),
IsExcluded: r == nil || r.ShouldExclude(),
} }
} }
return result return result