Documentation
¶
Overview ¶
Package stats parses JSONL usage log files and computes aggregate statistics with ASCII-formatted output.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearStats ¶
func ClearStats() error
ClearStats deletes all log files in the usage log directory.
func FormatRecentLogs ¶
FormatRecentLogs renders individual log entries as a per-request table.
func FormatStatsASCII ¶
func FormatStatsASCII(s AggregatedStats) string
FormatStatsASCII renders aggregated stats as an ASCII box art table.
Types ¶
type AggregatedStats ¶
type AggregatedStats struct {
Period string `json:"period"`
TotalRequests int `json:"totalRequests"`
TotalCost float64 `json:"totalCost"`
TotalBaselineCost float64 `json:"totalBaselineCost"`
TotalSavings float64 `json:"totalSavings"`
SavingsPercentage float64 `json:"savingsPercentage"`
AvgLatencyMs float64 `json:"avgLatencyMs"`
AvgCostPerRequest float64 `json:"avgCostPerRequest"`
ByTier map[string]TierStats `json:"byTier"`
ByModel map[string]ModelStats `json:"byModel"`
DailyBreakdown []DayStats `json:"dailyBreakdown"`
EntriesWithBaseline int `json:"entriesWithBaseline"`
}
AggregatedStats is the top-level stats result.
func GetStats ¶
func GetStats(days int) AggregatedStats
GetStats reads log files and returns aggregated statistics for the given number of days.
type DayStats ¶
type DayStats struct {
Date string `json:"date"`
TotalRequests int `json:"totalRequests"`
TotalCost float64 `json:"totalCost"`
TotalBaselineCost float64 `json:"totalBaselineCost"`
TotalSavings float64 `json:"totalSavings"`
AvgLatencyMs float64 `json:"avgLatencyMs"`
ByTier map[string]TierStats `json:"byTier"`
ByModel map[string]ModelStats `json:"byModel"`
}
DayStats holds one day of aggregated usage.
type ModelStats ¶
type ModelStats struct {
Count int `json:"count"`
Cost float64 `json:"cost"`
Percentage float64 `json:"percentage"`
}
ModelStats holds per-model aggregate data.
Click to show internal directories.
Click to hide internal directories.