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-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": {

View File

@@ -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'

View File

@@ -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 }

View File

@@ -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