Add IRateLimiterStatisticsFeature with default implementation and tests#46028
Add IRateLimiterStatisticsFeature with default implementation and tests#46028MadL1me wants to merge 8 commits intodotnet:mainfrom
Conversation
|
Thanks for your PR, @MadL1me. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
src/Middleware/RateLimiting/src/Features/IRateLimiterStatisticsFeature.cs
Outdated
Show resolved
Hide resolved
src/Middleware/RateLimiting/src/Features/IRateLimiterStatisticsFeature.cs
Outdated
Show resolved
Hide resolved
src/Middleware/RateLimiting/src/Features/DefaultRateLimiterStatisticsFeature.cs
Outdated
Show resolved
Hide resolved
src/Middleware/RateLimiting/src/Features/IRateLimiterStatisticsFeature.cs
Outdated
Show resolved
Hide resolved
src/Middleware/RateLimiting/src/Features/IRateLimiterStatisticsFeature.cs
Outdated
Show resolved
Hide resolved
src/Middleware/RateLimiting/src/Features/IRateLimiterStatisticsFeature.cs
Outdated
Show resolved
Hide resolved
src/Middleware/RateLimiting/src/Features/IRateLimiterStatisticsFeature.cs
Show resolved
Hide resolved
src/Middleware/RateLimiting/src/Features/IRateLimiterStatisticsFeature.cs
Outdated
Show resolved
Hide resolved
|
|
||
| private void AddRateLimiterStatisticsFeature(HttpContext context) | ||
| { | ||
| context.Features.Set<IRateLimiterStatisticsFeature>(new DefaultRateLimiterStatisticsFeature(_globalLimiter, _endpointLimiter, context)); |
There was a problem hiding this comment.
It looks like we can allocate this once and reuse it
|
|
||
| private void AddRateLimiterStatisticsFeature(HttpContext context) | ||
| { | ||
| _statisticsFeature?.SetHttpContext(context); |
There was a problem hiding this comment.
Oh, this stores the HttpContext, we need to allocate it every time then. You can't reuse it because parallel requests will end up accessing someone else's HttpContext.
There was a problem hiding this comment.
Sorry for the extra work, my bad 😄
|
We're still working on getting the right API for this. We will revisit the API again on Monday. |
|
@halter73 no problem, take as much time as you need - its better to ship well designed API than poorly designed, and I appreciate your time and work for this |
|
@dotnet-policy-service agree |
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
|
@MadL1me can you change this PR to a Draft PR for now? Hopefully we can figure something out for this soon. |
|
Yeah, sure |
Add IRateLimiterStatisticsFeature with default implementation and tests
This PR implements first half of this proposed API for RateLimiterMiddleware. Relates to: #44140.
Description
Based on 1 of 2 parts from this API proposal: #45658.
In this PR:
RateLimiterOptions.TrackStatistics