mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 16:41:54 +08:00
- Implement status code statistics tracking in Collector - Update PathMetrics type to use pointer-based access - Enhance atomic operations for request and error count tracking - Modify type assertions to use pointer-based type conversion
32 lines
805 B
Go
32 lines
805 B
Go
package models
|
|
|
|
import (
|
|
"sync/atomic"
|
|
)
|
|
|
|
type PathStats struct {
|
|
Requests atomic.Int64
|
|
Errors atomic.Int64
|
|
Bytes atomic.Int64
|
|
LatencySum atomic.Int64
|
|
}
|
|
|
|
// PathMetrics 路径指标
|
|
type PathMetrics struct {
|
|
Path string `json:"path"`
|
|
RequestCount int64 `json:"request_count"`
|
|
ErrorCount int64 `json:"error_count"`
|
|
TotalLatency int64 `json:"total_latency"`
|
|
BytesTransferred int64 `json:"bytes_transferred"`
|
|
AvgLatency string `json:"avg_latency"`
|
|
}
|
|
|
|
type HistoricalMetrics struct {
|
|
Timestamp string `json:"timestamp"`
|
|
TotalRequests int64 `json:"total_requests"`
|
|
TotalErrors int64 `json:"total_errors"`
|
|
TotalBytes int64 `json:"total_bytes"`
|
|
ErrorRate float64 `json:"error_rate"`
|
|
AvgLatency float64 `json:"avg_latency"`
|
|
}
|