Skip to content

Commit a620d45

Browse files
authored
Return slowlog complexity info if available
based on redis#622
1 parent bc58542 commit a620d45

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

redis/client.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,22 @@ def parse_zscan(response, **options):
400400

401401
def parse_slowlog_get(response, **options):
402402
space = ' ' if options.get('decode_responses', False) else b' '
403-
return [{
404-
'id': item[0],
405-
'start_time': int(item[1]),
406-
'duration': int(item[2]),
407-
'command':
408-
# Redis Enterprise injects another entry at index [3], which has
409-
# the complexity info (i.e. the value N in case the command has
410-
# an O(N) complexity) instead of the command.
411-
space.join(item[3]) if isinstance(item[3], list) else
412-
space.join(item[4])
413-
} for item in response]
403+
def parse_item(item):
404+
result = {
405+
'id': item[0],
406+
'start_time': int(item[1]),
407+
'duration': int(item[2]),
408+
}
409+
# Redis Enterprise injects another entry at index [3], which has
410+
# the complexity info (i.e. the value N in case the command has
411+
# an O(N) complexity) instead of the command.
412+
if isinstance(item[3], list):
413+
result['command'] = space.join(item[3])
414+
else:
415+
result['complexity'] = item[3]
416+
result['command'] = space.join(item[4])
417+
return result
418+
return [parse_item(item) for item in response]
414419

415420

416421
def parse_cluster_info(response, **options):

0 commit comments

Comments
 (0)