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
25 changes: 15 additions & 10 deletions ddtrace/contrib/redis/tracers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ def __init__(self, *args, **kwargs):
super(TracedPipeline, self).__init__(*args, **kwargs)

def execute(self, *args, **kwargs):
commands, queries = [], []
queries = []
with self._datadog_tracer.trace('redis.pipeline') as s:
if s.sampled:
s.service = self._datadog_service
s.span_type = redisx.TYPE

for cargs, _ in self.command_stack:
commands.append(cargs[0])
queries.append(format_command_args(cargs))

s.set_tag(redisx.CMD, ', '.join(commands))
query = '\n'.join(queries)
s.resource = query
# non quantized version
s.set_tag(redisx.RAWCMD, query)

s.set_tags(_extract_conn_tags(self.connection_pool.connection_kwargs))
s.set_tags(self._datadog_meta)
Expand All @@ -69,9 +69,12 @@ def immediate_execute_command(self, *args, **kwargs):
if s.sampled:
s.service = self._datadog_service
s.span_type = redisx.TYPE
# currently no quantization on the client side
s.resource = format_command_args(args)
s.set_tag(redisx.CMD, (args or [None])[0])

query = format_command_args(args)
s.resource = query
# non quantized version
s.set_tag(redisx.RAWCMD, query)

s.set_tags(_extract_conn_tags(self.connection_pool.connection_kwargs))
s.set_tags(self._datadog_meta)
# FIXME[leo]: convert to metric?
Expand All @@ -93,12 +96,14 @@ def set_datadog_meta(cls, meta):
def execute_command(self, *args, **options):
with self._datadog_tracer.trace('redis.command') as s:
if s.sampled:
command_name = args[0]
s.service = self._datadog_service
s.span_type = redisx.TYPE
# currently no quantization on the client side
s.resource = format_command_args(args)
s.set_tag(redisx.CMD, (args or [None])[0])

query = format_command_args(args)
s.resource = query
# non quantized version
s.set_tag(redisx.RAWCMD, query)

s.set_tags(_extract_conn_tags(self.connection_pool.connection_kwargs))
s.set_tags(self._datadog_meta)
# FIXME[leo]: convert to metric?
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/ext/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DB = 'out.redis_db'

# standard tags
CMD = 'redis.command'
RAWCMD = 'redis.raw_command'
ARGS_LEN = 'redis.args_length'
PIPELINE_LEN = 'redis.pipeline_length'
PIPELINE_AGE = 'redis.pipeline_age'
Expand Down