Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ddtrace/contrib/redis/util.py
Original file line number Diff line number Diff line change
@@ -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 = "?"
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import os

tests_require = [
'nose',
'flask',
'blinker',
'cassandra-driver',
'django',
'elasticsearch',
'flask',
'nose',
'psycopg2',
'django',
'cassandra-driver',
'redis',
]

version = __version__
Expand Down
7 changes: 5 additions & 2 deletions tests/contrib/redis/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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


Expand Down