Documentation
¶
Index ¶
- func GetStatsPath() (string, error)
- type APIResponse
- type DailyStats
- type EndpointStats
- type Proxy
- type SSEEvent
- type Stats
- func (s *Stats) CleanupOldData(daysToKeep int)
- func (s *Stats) GetDailyStats(date string) map[string]*DailyStats
- func (s *Stats) GetPeriodStats(startDate, endDate string) map[string]*DailyStats
- func (s *Stats) GetStats() (int, map[string]*EndpointStats)
- func (s *Stats) Load() error
- func (s *Stats) RecordError(endpointName string)
- func (s *Stats) RecordRequest(endpointName string)
- func (s *Stats) RecordTokens(endpointName string, inputTokens, outputTokens int)
- func (s *Stats) Reset()
- func (s *Stats) Save() error
- func (s *Stats) SetStatsPath(path string)
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStatsPath ¶ added in v0.5.2
GetStatsPath returns the stats file path
Types ¶
type APIResponse ¶
type APIResponse struct {
Usage Usage `json:"usage"`
}
APIResponse represents the structure of API responses to extract usage
type DailyStats ¶ added in v1.4.0
type DailyStats struct {
Date string `json:"date"` // Format: "2006-01-02"
Requests int `json:"requests"`
Errors int `json:"errors"`
InputTokens int `json:"inputTokens"`
OutputTokens int `json:"outputTokens"`
}
DailyStats represents statistics for a single day
type EndpointStats ¶
type EndpointStats struct {
Requests int `json:"requests"`
Errors int `json:"errors"`
InputTokens int `json:"inputTokens"`
OutputTokens int `json:"outputTokens"`
LastUsed time.Time `json:"lastUsed"`
DailyHistory map[string]*DailyStats `json:"dailyHistory,omitempty"` // Key: date string
}
EndpointStats represents statistics for a single endpoint
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy represents the proxy server
func (*Proxy) GetCurrentEndpointName ¶ added in v1.1.1
GetCurrentEndpointName returns the current endpoint name (thread-safe)
func (*Proxy) SetCurrentEndpoint ¶ added in v1.1.1
SetCurrentEndpoint manually switches to a specific endpoint by name Returns error if endpoint not found or not enabled Thread-safe and won't affect ongoing requests
type Stats ¶
type Stats struct {
TotalRequests int `json:"totalRequests"`
EndpointStats map[string]*EndpointStats `json:"endpointStats"`
// contains filtered or unexported fields
}
Stats represents overall proxy statistics
func (*Stats) CleanupOldData ¶ added in v1.4.0
CleanupOldData removes data older than specified days
func (*Stats) GetDailyStats ¶ added in v1.4.0
func (s *Stats) GetDailyStats(date string) map[string]*DailyStats
GetDailyStats returns statistics for a specific date
func (*Stats) GetPeriodStats ¶ added in v1.4.0
func (s *Stats) GetPeriodStats(startDate, endDate string) map[string]*DailyStats
GetPeriodStats returns aggregated statistics for a time period
func (*Stats) GetStats ¶
func (s *Stats) GetStats() (int, map[string]*EndpointStats)
GetStats returns a copy of current statistics (thread-safe)
func (*Stats) RecordError ¶
RecordError records an error for an endpoint
func (*Stats) RecordRequest ¶
RecordRequest records a request for an endpoint
func (*Stats) RecordTokens ¶
RecordTokens records token usage for an endpoint
func (*Stats) SetStatsPath ¶ added in v0.5.2
SetStatsPath sets the path for stats persistence