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. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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.