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 78d898b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ddtrace/contrib/dalli/quantize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module Quantize
def format_command(operation, args)
command = [operation, *args].join(' ').strip
Utils.truncate(command, MAX_CMD_LENGTH)
rescue ::Encoding::CompatibilityError => e
"#{operation} BLOB (OMITTED)"
end
end
end
Expand Down
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 78d898b

Please sign in to comment.