Repository navigation
fix(logger): exclude asyncio task name from log lines - #8840
leandrodamascena merged 2 commits 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. |
|
@leandrodamascena, I added I might look into the derived-list approach later on. |
leandrodamascena
left a comment
There was a problem hiding this comment.
Thanks @eminfikret! One line in the right place and a test that shows the bug. Goes out in 3.42.0, no need to rebase, you'll be in the release notes.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8840 +/- ##
========================================
Coverage 97.20% 97.20%
========================================
Files 327 327
Lines 16759 16759
Branches 1523 1523
========================================
Hits 16290 16290
Misses 328 328
Partials 141 141 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |



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.