uranusjr commented on a change in pull request #15469:
URL: https://github.com/apache/airflow/pull/15469#discussion_r617450392
##########
File path: airflow/providers/elasticsearch/log/es_task_handler.py
##########
@@ -129,10 +129,11 @@ def _group_logs_by_host(logs):
key = getattr(log, 'host', 'default_host')
grouped_logs[key].append(log)
- # return items sorted by timestamp.
- result = sorted(grouped_logs.items(), key=lambda kv: getattr(kv[1][0],
'message', '_'))
+ # return items sorted by asctime.
+ for host in grouped_logs:
+ grouped_logs[host].sort(key=lambda log: getattr(log, 'asctime',
'_'))
Review comment:
```suggestion
def sorter(log):
return getattr(log, 'asctime', '_')
for logs in grouped_logs.values():
logs.sort(key=sorter)
```
Repeated lambda definition inside a loop is slow.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]