Skip to content

Commit 8c5eca9

Browse files
authored
Merge pull request #44 from flatrun/feat/traffic-dashboard-redesign
feat(traffic): add deployment context to PathStats
2 parents 08fb25d + 09241a2 commit 8c5eca9

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

internal/traffic/db.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,20 +284,20 @@ func (db *DB) GetStats(deploymentName string, since time.Duration) (*TrafficStat
284284
}
285285
}
286286

287-
// Top paths
287+
// Top paths with deployment context
288288
rows, err = db.conn.Query(`
289-
SELECT request_path, COUNT(*) as cnt, AVG(response_time_ms) as avg_time,
289+
SELECT deployment_name, request_path, COUNT(*) as cnt, AVG(response_time_ms) as avg_time,
290290
SUM(CASE WHEN status_code >= 400 THEN 1 ELSE 0 END) as errors
291291
FROM traffic_logs
292292
WHERE created_at >= ?`+deploymentFilter+`
293-
GROUP BY request_path
294-
ORDER BY cnt DESC
293+
GROUP BY deployment_name, request_path
294+
ORDER BY avg_time DESC
295295
LIMIT 10`, args...)
296296
if err == nil {
297297
defer rows.Close()
298298
for rows.Next() {
299299
var p PathStats
300-
if err := rows.Scan(&p.Path, &p.RequestCount, &p.AvgTimeMs, &p.ErrorCount); err == nil {
300+
if err := rows.Scan(&p.Deployment, &p.Path, &p.RequestCount, &p.AvgTimeMs, &p.ErrorCount); err == nil {
301301
stats.TopPaths = append(stats.TopPaths, p)
302302
}
303303
}

internal/traffic/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type TrafficStats struct {
4444

4545
type PathStats struct {
4646
Path string `json:"path"`
47+
Deployment string `json:"deployment"`
4748
RequestCount int64 `json:"request_count"`
4849
AvgTimeMs float64 `json:"avg_time_ms"`
4950
ErrorCount int64 `json:"error_count"`

0 commit comments

Comments
 (0)