Repository navigation
fix(logger): exclude asyncio task name from log lines - #8840
Open
eminfikret wants to merge 1 commit into
Open
eminfikret wants to merge 1 commit into
eminfikret wants to merge 1 commit into
Conversation
Python 3.12+ added taskName to LogRecord, so every log emitted inside an asyncio task carried an unwanted taskName key. - add taskName to RESERVED_LOG_ATTRS - add a test that logs inside asyncio.run and asserts taskName is absent Closes aws-powertools#8826 Signed-off-by: Emin Fikret <emin.n.fikret@gmail.com> Assisted-by: Claude Opus 5.5
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
|
Author
|
@leandrodamascena, I added I might look into the derived-list approach later on. |



Issue number: closes #8826
Summary
Python 3.12 added
taskNametoLogRecord. It wasn't inRESERVED_LOG_ATTRS, so the formatter added it to every log line emitted inside an asyncio task. This removes it.Changes
taskNametoRESERVED_LOG_ATTRSinaws_lambda_powertools/logging/formatter.py.test_log_dict_task_name_is_not_present_when_inside_asyncio_taskintests/functional/logger/required_dependencies/test_logger_powertools_formatter.py.User experience
"taskName": "Task-1".taskName, so they have the same keys inside and outside an asyncio task.Verification
developand passes with the fix (Python 3.13.5).make prpasses.I used an AI assistant (Claude) as a tutor and reviewer; I wrote and ran the change and the tests myself.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.