feat: add API key usage endpoint with provider and key grouping
- Implemented `GetAPIKeyUsage` to expose recent request data grouped by provider and API key. - Added supporting function `mergeRecentRequestBuckets` for bucket aggregation. - Registered new endpoint `/v0/management/api-key-usage` in the management API. - Included extensive unit tests for provider and key-based grouping validation. - Updated `formatRecentRequestBucketLabel` to support configurable bucket duration.
This commit is contained in:
@@ -164,7 +164,7 @@ func recentRequestBucketIndex(bucketID int64) int {
|
||||
|
||||
func formatRecentRequestBucketLabel(bucketID int64) string {
|
||||
start := time.Unix(bucketID*recentRequestBucketSeconds, 0).In(time.Local)
|
||||
end := start.Add(10 * time.Minute)
|
||||
end := start.Add(time.Duration(recentRequestBucketSeconds) * time.Second)
|
||||
return start.Format("15:04") + "-" + end.Format("15:04")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user