Skip to content

Commit

Permalink
Add queue name to logs (#201)
Browse files Browse the repository at this point in the history
* Log queue name

* Update tasktiger_processor's docstring

* Check that queue name is logged

* Fix test comment
  • Loading branch information
drewler authored Dec 2, 2021
1 parent f3b3e24 commit a090d00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions tasktiger/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ def tasktiger_processor(logger, method_name, event_dict):
"""
TaskTiger structlog processor.
Inject the current task id for non-batch tasks.
Inject the current task ID and queue for non-batch tasks.
"""

if g['current_tasks'] is not None and not g['current_task_is_batch']:
event_dict['task_id'] = g['current_tasks'][0].id
current_task = g['current_tasks'][0]
event_dict['task_id'] = current_task.id
event_dict['queue'] = current_task.queue

return event_dict
3 changes: 2 additions & 1 deletion tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

def logging_task():
log = logger.info("simple task")
# Confirm tasktiger_processor injected task id
# Confirm tasktiger_processor injected task id and queue name
assert log[1]["task_id"] == tiger.current_task.id
assert log[1]["queue"] == tiger.current_task.queue


class TestLogging(BaseTestCase):
Expand Down

0 comments on commit a090d00

Please sign in to comment.