-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix shadow mode metric is not collected when local cache hit #424
Conversation
Signed-off-by: Seonghyun Oh <seonghyunoh@gmail.com>
fc22497
to
f9c6402
Compare
assert.Equal(uint64(1), limits[0].Stats.NearLimit.Value()) | ||
assert.Equal(uint64(3), limits[0].Stats.WithinLimit.Value()) | ||
assert.Equal(uint64(2), limits[0].Stats.WithinLimit.Value()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value should be 2. Please refer to the original test code for local cache.
(Even if shadow mode is enabled, this value should not be changed.)
ratelimit/test/redis/fixed_cache_impl_test.go
Lines 276 to 280 in b3562ca
assert.Equal(uint64(4), limits[0].Stats.TotalHits.Value()) | |
assert.Equal(uint64(2), limits[0].Stats.OverLimit.Value()) | |
assert.Equal(uint64(1), limits[0].Stats.OverLimitWithLocalCache.Value()) | |
assert.Equal(uint64(1), limits[0].Stats.NearLimit.Value()) | |
assert.Equal(uint64(2), limits[0].Stats.WithinLimit.Value()) |
} | ||
|
||
isOverLimitWithLocalCache[i] = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Shadow mode and local cache should be irrelevant.
- If the local cache is hit, the continue statement does not perform the INCR command, but the GetResponseDescriptorStatus method does not handle it properly.
@@ -80,9 +80,9 @@ func (this *BaseRateLimiter) GetResponseDescriptorStatus(key string, limitInfo * | |||
nil, 0) | |||
} | |||
var responseDescriptorStatus *pb.RateLimitResponse_DescriptorStatus | |||
over_limit := false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not follow the Golang naming convention.
Can you check CI? Not sure if it's a flake or not. |
@mattklein123 |
Signed-off-by: Seonghyun Oh <seonghyunoh@gmail.com>
Signed-off-by: Seonghyun Oh <seonghyunoh@gmail.com>
Description
This PR fixes #423 issue where statistics were not collected correctly when hitting the local cache.
If the local cache is hit, the rate limit service does not perform the INCR command, but the GetResponseDescriptorStatus method does not handle it properly.
Invalid metric
shadow mode stats are not collected for the actual number of requests.
Expected
shadow mode stat should be the same value as over limit .