Skip to content

Commit

Permalink
Fix dalli instrumentation encoding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
p-lambert committed Dec 6, 2017
1 parent 982e5e9 commit 968d804
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ddtrace/contrib/dalli/quantize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ module Quantize
def format_command(operation, args)
command = [operation, *args].join(' ').strip
Utils.truncate(command, MAX_CMD_LENGTH)
rescue ::Encoding::CompatibilityError
"#{operation} BLOB (OMITTED)"
end
end
end
end
end
n
7 changes: 7 additions & 0 deletions test/contrib/dalli/quantize_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def test_command_truncation
assert(command.end_with?('...'))
assert_equal('set foo ' + 'A' * 89 + '...', command)
end

def test_regression_different_encodings
op = :set
args = ["\xa1".force_encoding('iso-8859-1'), "\xa1\xa1".force_encoding('euc-jp')]

assert_match(/BLOB \(OMITTED\)/, Quantize.format_command(op, args))
end
end
end
end
Expand Down

0 comments on commit 968d804

Please sign in to comment.