-
Notifications
You must be signed in to change notification settings - Fork 865
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 scrapping for redis < 4.0 #860
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,10 @@ for i=3,#ARGV do | |
end | ||
end | ||
for i,key in ipairs(batch[2]) do | ||
usage = redis.call("MEMORY", "USAGE", key) | ||
local reply = redis.pcall("MEMORY", "USAGE", key) | ||
if type(reply) == "number" then | ||
usage = reply; | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question, should you exit if you don't get a value for usage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello, local usage variable is initialized to 0 so no problem on line 193/195, is value will stay to 0 if MEMORY do not work The idea is to obtain at less key_groups count on redis version prior to 4.0, groups will always contain 0 for memory usage but the correct count. A possibility to make it better should be to not generate memory usage metrics when not available... but it's more complex and need more code modifications (but it is possible to do it ;-) ). The current workaround make possible to use a limited key_groups scrapping that i think is better than the today error that generate nothing for key_group for legacy redis. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense, thanks for the explanation! |
||
group = nil | ||
for i=3,#ARGV do | ||
key_match_result = {string.find(key, ARGV[i])} | ||
|
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 doesn't seem to work, see the tests:
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.
oups, my bads i haven't tested on a version that was supporting MEMORY command.
It should be better now by checking the returned type
1bc1b45
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.
Looks good now, thanks!