feat(usage): add in-memory usage statistics tracking and API endpoint

- Introduced in-memory request statistics aggregation in `LoggerPlugin`.
- Added new structures for detailed metrics collection (e.g., token breakdown, request success/failure).
- Implemented `/usage` management API endpoint for retrieving aggregated statistics.
- Updated management handlers to support the new usage statistics functionality.
- Enhanced documentation to describe the usage metrics API.
This commit is contained in:
Luis Pater
2025-09-25 01:06:02 +08:00
parent 0db0b03db9
commit 19609db13c
7 changed files with 434 additions and 40 deletions

View File

@@ -271,6 +271,7 @@ func (s *Server) setupRoutes() {
mgmt := s.engine.Group("/v0/management")
mgmt.Use(s.mgmt.Middleware())
{
mgmt.GET("/usage", s.mgmt.GetUsageStatistics)
mgmt.GET("/config", s.mgmt.GetConfig)
mgmt.GET("/debug", s.mgmt.GetDebug)