diff --git a/ddtrace/contrib/redis/util.py b/ddtrace/contrib/redis/util.py index 01875b55e65..2454cb5e1d6 100644 --- a/ddtrace/contrib/redis/util.py +++ b/ddtrace/contrib/redis/util.py @@ -1,6 +1,7 @@ """ Some utils used by the dogtrace redis integration """ +from ...compat import stringify from ...ext import redis as redisx, net VALUE_PLACEHOLDER = "?" @@ -32,7 +33,7 @@ def format_command_args(args): formatted_args = [] for arg in args: try: - command = unicode(arg) + command = stringify(arg) if len(command) > VALUE_MAX_LENGTH: command = command[:VALUE_MAX_LENGTH] + VALUE_TOO_LONG_MARK if formatted_length + len(command) > COMMAND_MAX_LENGTH: diff --git a/setup.py b/setup.py index bca41ccc466..2f6e83a412a 100644 --- a/setup.py +++ b/setup.py @@ -3,13 +3,14 @@ import os tests_require = [ - 'nose', - 'flask', 'blinker', + 'cassandra-driver', + 'django', 'elasticsearch', + 'flask', + 'nose', 'psycopg2', - 'django', - 'cassandra-driver', + 'redis', ] version = __version__ diff --git a/tests/contrib/redis/test.py b/tests/contrib/redis/test.py index b7911c06635..6561fea9111 100644 --- a/tests/contrib/redis/test.py +++ b/tests/contrib/redis/test.py @@ -45,7 +45,7 @@ def test_basic_class(self): eq_(span.name, 'redis.command') eq_(span.span_type, 'redis') eq_(span.error, 0) - eq_(span.meta, {'out.host': u'localhost', 'redis.command': u'GET', 'out.port': u'6379', 'redis.args_length': u'2', 'out.redis_db': u'0'}) + eq_(span.meta, {'out.host': u'localhost', 'redis.raw_command': u'GET cheese', 'out.port': u'6379', 'redis.args_length': u'2', 'out.redis_db': u'0'}) eq_(span.resource, 'GET cheese') def test_meta_override(self): @@ -87,14 +87,17 @@ def test_basic_class_pipeline(self): eq_(span.get_tag('out.host'), 'localhost') ok_(float(span.get_tag('redis.pipeline_age')) > 0) eq_(span.get_tag('redis.pipeline_length'), '3') - eq_(span.get_tag('redis.command'), 'SET, RPUSH, HGETALL') eq_(span.get_tag('out.port'), '6379') eq_(span.resource, u'SET blah 32\nRPUSH foo éé\nHGETALL xxx') + eq_(span.get_tag('redis.raw_command'), u'SET blah 32\nRPUSH foo éé\nHGETALL xxx') def test_custom_class(self): class MyCustomRedis(redis.Redis): def execute_command(self, *args, **kwargs): response = super(MyCustomRedis, self).execute_command(*args, **kwargs) + # py3 compat + if isinstance(response, bytes): + response = response.decode('utf-8') return 'YO%sYO' % response