-
Notifications
You must be signed in to change notification settings - Fork 1
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
Improve key quantization and add command length #19
base: deployed-in-platform
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -6,12 +6,32 @@ module Contrib | |
module Dalli | ||
# Quantize contains dalli-specic quantization tools. | ||
module Quantize | ||
# BEGIN BRAZE MODIFICATION | ||
GUID_ID_REGEX = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i | ||
BSON_ID_REGEX = /[0-9a-f]{24}/i | ||
XXHASH_REGEX = /[0-9a-f]{16}/ | ||
INTEGER_ID_REGEX = /\d+/ | ||
# END BRAZE MODIFICATION | ||
module_function | ||
|
||
def format_command(operation, args) | ||
placeholder = "#{operation} BLOB (OMITTED)" | ||
command = [operation, *args].join(' ').strip | ||
# BEGIN BRAZE MODIFICATION | ||
if operation == :send_multiget | ||
command = [operation, *args].join(' ').strip | ||
else | ||
# all operations except multiget have the key as the first arg | ||
command = [operation, args[0]].join(' ').strip | ||
end | ||
# END BRAZE MODIFICATION | ||
|
||
command = Core::Utils.utf8_encode(command, binary: true, placeholder: placeholder) | ||
# BEGIN BRAZE MODIFICATION | ||
command = command.gsub(GUID_ID_REGEX, "GUID") | ||
command = command.gsub(BSON_ID_REGEX, "BSON") | ||
command = command.gsub(XXHASH_REGEX, "XXHASH") | ||
command = command.gsub(INTEGER_ID_REGEX, "INTEGER") | ||
Comment on lines
+30
to
+33
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. this could have negative perf impact, also 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. I don't think this will be too bad, but I'm curious if there are some relatively quick ideas we could do to make this faster. I could smush all of these together into a single expression and just replace it with |
||
# END BRAZE MODIFICATION | ||
Core::Utils.truncate(command, Ext::QUANTIZE_MAX_CMD_LENGTH) | ||
rescue => e | ||
Datadog.logger.debug("Error sanitizing Dalli operation: #{e}") | ||
|
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.
the
Quantize.format_command(op, args)
abovealready ran
Core::Utils.utf8_encode(command, binary: true, placeholder: placeholder)
I think it would be better to only run that once, the cost of this observability is pretty high already for the use of dalli, which gets used all the time.
Also, should this tag only be added when
datadog_configuration[:command_enabled]
is true?