Skip to content

Conversation

landonxjames
Copy link
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@landonxjames landonxjames marked this pull request as ready for review October 8, 2025 18:10
@landonxjames landonxjames requested a review from a team as a code owner October 8, 2025 18:10
pub(crate) struct TokenBucketMetrics {
max_tokens: u64,
available_tokens: UpDownCounter,
token_wait_time: Histogram,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this will be meaningful or not given permit requests come with different token amounts requested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if tracking percentage of available tokens over time or something would be more useful?

// NOTE: tokio semaphore is fair, permits are given out in the order requested
semaphore: Arc<Semaphore>,
mode: ConcurrencyMode,
tb_metrics: Arc<TokenBucketMetrics>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm kind of wondering whether token bucket metrics provide value at this point in time. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am also not sure, but will probably leave them in place until I can actually run some benchmarks and test all of this on some real use cases. Can remove if we find it not necessary after that testing.

Remove permit acquisition/release tracking and simplify inflight
request monitoring with consistent counter types.
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