mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 08:31:55 +08:00
fix(metrics): update AvgLatency type and improve SQL query for metrics retrieval
- Changed AvgLatency field type from int64 to float64 in HistoricalMetrics for better precision in latency measurements. - Updated SQL query in GetRecentMetrics to ensure proper averaging of AvgLatency by casting to float, enhancing accuracy in metrics reporting. - These changes improve the reliability of metrics data and ensure more accurate performance monitoring.
This commit is contained in:
parent
a009dd04a8
commit
60b115438a
@ -32,7 +32,7 @@ type HistoricalMetrics struct {
|
||||
TotalErrors int64 `json:"total_errors"`
|
||||
TotalBytes int64 `json:"total_bytes"`
|
||||
ErrorRate float64 `json:"error_rate"`
|
||||
AvgLatency int64 `json:"avg_latency"`
|
||||
AvgLatency float64 `json:"avg_latency"`
|
||||
}
|
||||
|
||||
type PathMetrics struct {
|
||||
@ -247,10 +247,10 @@ func (db *MetricsDB) GetRecentMetrics(hours int) ([]HistoricalMetrics, error) {
|
||||
SUM(total_requests) as total_requests,
|
||||
SUM(total_errors) as total_errors,
|
||||
SUM(total_bytes) as total_bytes,
|
||||
AVG(avg_latency) as avg_latency
|
||||
CAST(AVG(CAST(avg_latency AS FLOAT)) AS FLOAT) as avg_latency
|
||||
FROM metrics_history
|
||||
WHERE timestamp >= datetime('now', '-' || ?2 || ' hours')
|
||||
GROUP BY group_time
|
||||
GROUP BY group_time
|
||||
ORDER BY group_time DESC
|
||||
)
|
||||
SELECT * FROM grouped_metrics
|
||||
|
Loading…
x
Reference in New Issue
Block a user