Skip to content

Print out cache hit ratio on provider-proxy shutdown#7524

Open
Aaron1011 wants to merge 1 commit into
mainfrom
aaron/provider-proxy-stats
Open

Print out cache hit ratio on provider-proxy shutdown#7524
Aaron1011 wants to merge 1 commit into
mainfrom
aaron/provider-proxy-stats

Conversation

@Aaron1011
Copy link
Copy Markdown
Member

@Aaron1011 Aaron1011 commented May 28, 2026

This will make it easier to debug any issues that show up when using provider-proxy in external projects


Note

Low Risk
Observability and graceful shutdown wiring only; request caching and forwarding logic are unchanged aside from counters.

Overview
Adds lifetime cache hit tracking for provider-proxy and logs a summary when the process exits.

A new CacheStats type counts total proxied cache lookups and hits (atomics, relaxed ordering). check_cache records each completed lookup—including early ReadOnlyRequireHit misses—before returning.

Shutdown is now driven by tokio::select!: the MITM server runs until it finishes or until Ctrl-C / SIGTERM (Unix). On exit, an info log prints hits, total requests, and the hit percentage.

This does not change cache keys, storage, or proxy behavior beyond counting and graceful signal handling for the stats line.

Reviewed by Cursor Bugbot for commit 0c532c5. Configure here.

This will make it easier to debug any issues that show up
when using provider-proxy in external projects
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0c532c5. Configure here.

async fn shutdown_signal() {
let ctrl_c = async {
let _ = tokio::signal::ctrl_c().await;
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctrl_c error causes immediate proxy shutdown

Medium Severity

The ctrl_c async block discards the Result from tokio::signal::ctrl_c().await with let _ =, causing the block to complete immediately if signal registration fails. This makes shutdown_signal() resolve right away, shutting down the proxy on startup. The SIGTERM handler correctly avoids this by calling std::future::pending::<()>().await on error, but the ctrl_c handler lacks the same safeguard.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0c532c5. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants