Add rate-limited and aggregate logging to reduce log volume at high load#859
Open
dsingal0 wants to merge 1 commit intohuggingface:mainfrom
Open
Add rate-limited and aggregate logging to reduce log volume at high load#859dsingal0 wants to merge 1 commit intohuggingface:mainfrom
dsingal0 wants to merge 1 commit intohuggingface:mainfrom
Conversation
At high load, logging every request can be overwhelming for logging solutions like Loki. This commit introduces two new CLI arguments: - --log-sample-rate: Controls maximum request success logs per second (default: 10, set to 0 to disable per-request logging) - --log-aggregate-interval: Interval in seconds for logging aggregate statistics (default: 0 = disabled) The aggregate logger provides periodic summaries including request count, error count, characters processed, and tokens processed per interval, giving better observability while dramatically reducing log volume. Example aggregate log: 'Request aggregate: 5234 requests (87.2/s), 12 errors | 10456789 chars (174280/s) | 2345678 tokens (39094/s)' Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
At high load, logging every request can be overwhelming for logging solutions like Loki. This PR introduces two new CLI arguments to provide flexible logging controls:
New CLI Arguments
--log-sample-rate: Controls maximum request success logs per second (default: 10, set to 0 to disable per-request logging)--log-aggregate-interval: Interval in seconds for logging aggregate statistics (default: 0 = disabled)Features
Rate-Limited Logger
Aggregate Logger
Usage Examples
Both options can also be configured via environment variables:
LOG_SAMPLE_RATE(default: 10)LOG_AGGREGATE_INTERVAL(default: 0)Files Changed
router/src/logging.rs- Added RateLimitedLogger and AggregateLogger implementationsrouter/src/main.rs- Added CLI argumentsrouter/src/lib.rs- Updated run() signature to pass loggersrouter/src/http/server.rs- Updated all 6 endpoint handlers to use new loggersREADME.md- Added comprehensive documentation for the new featuresBenefits
✅ Reduces logging overhead at high load
✅ Provides better observability through aggregate statistics
✅ Backward compatible - defaults similar to current behavior
✅ Works seamlessly with Loki and other log aggregation solutions
✅ Configurable via CLI args or environment variables