Feat/optimize logging - #1691
Conversation
Feat/monitor
fix slave metrics
Billing export
Feat/model search
Feat/adjust err
Billing optim
|
Caution Review failedThe pull request is closed. WalkthroughSwitches CI to build/push a NewAPI Docker image to Tencent Cloud. Overhauls Dockerfile/runtime (private bases, log rotation, entrypoint). Adds logging, metrics, pprof toggle, traffic monitoring, request persistence, and extensive relay refactors (info/execute split, proxy mode, new XAI channel, Volcengine batch). Expands models/migrations, controllers, middleware, DTOs, and routes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant Gin as Gin Router
participant MW as Middleware (Auth/Logger/Traffic)
participant Relay as Relay (Info/Execute)
participant Adaptor as Channel Adaptor
participant Upstream as Upstream API
participant Metrics as Metrics
participant Persist as Request Persistence
Client->>Gin: HTTP request
Gin->>MW: Auth + RequestID + Logger + Traffic
MW-->>Gin: Context (user, token, headers)
Gin->>Relay: TextInfo/ImageInfo/... (parse + validate)
Relay->>Adaptor: Convert + DoRequest
Adaptor->>Upstream: HTTP request (propagated headers)
Upstream-->>Adaptor: HTTP response (stream/non-stream)
Adaptor-->>Relay: Response + Usage/Status
Relay->>Metrics: Counters + Duration + Tokens
alt Persistence enabled and OK
Relay->>Persist: Save request/response snapshot
end
Relay-->>Client: Proxied response
MW->>MW: RecordRequestEnd()
sequenceDiagram
autonumber
participant Client
participant Gin
participant Relay as Relay (Proxy/Batch)
participant VE as Volcengine Batch
participant Redis as Redis Cache/Lock
participant KA as KeepAlive Manager
Client->>Gin: POST /v1beta/models/* (batch)
Gin->>Relay: Proxy/Batch handler
Relay->>Redis: TryAcquireLock(requestID)
alt Lock exists
Relay-->>Client: 409 conflict (retry_request_id)
else Lock acquired
Relay->>KA: AddBatchResultKey(requestID)
Relay->>Redis: CreateBatchRequestKey(pending, TTL)
par Async batch call
Relay->>VE: CreateBatchChatCompletion(...)
VE-->>Relay: Result/Error
Relay->>Redis: SaveBatchResult/SaveBatchError (24h TTL)
and Wait
Relay-->>Client: 203 accepted with retry_request_id on timeout
Note over Relay,Client: On subsequent poll, returns cached result
end
end
Estimated code review effort🎯 5 (Critical) | ⏱️ ~180 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
…ld dedup Fixes QuantumNous#1691 - pollOutbox() reused a 10s context for SetOutboxWatermark after event processing could take much longer, causing "outbox watermark write failed: context deadline exceeded". The watermark never advanced so the same 200 events were reprocessed every poll cycle, spiking CPU. Now uses an independent 5s context with up to 3 retries (200ms apart). - When multiple Codex accounts sharing the same 21-22 groups are all rate-limited in quick succession, each account_changed event triggered redundant bucket rebuild attempts for the same groups. Introduce batchSeenKey{groupID, platform} and thread a seen map through the handler chain; rebuildBucketsForPlatform skips (group, platform) pairs already rebuilt within the same poll batch (~80% fewer rebuild calls in the 5-accounts-same-groups scenario). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Summary by CodeRabbit
New Features
Improvements
Documentation
Chores