You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just like in the TypeScript version, add a new optional parameter to the Logger initializer. For example, the new option can be called persistent_keys.
This parameter could be a simple flat dict(or similar type?), and if not provided, default to an empty dict.
The value of this new parameter could either be added to self._default_log_keys(since what ever is in that already persists through a state clearing) or be maintained separately but treated just like self._default_log_keys.
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
Hi @jth08527! Thanks a lot for opening this issue! I'll need to do some research on the impact of this issue because I don't know if the API will be confused with append_keys and persistent_keys. I'm adding this to our backlog and aiming to take a look at it later this month.
Use case
Add custom keys to logs that should persist on every lambda execution and NOT be cleared when using clear_state.
This functionality already exists in the TypeScript version of powertools and can be useful for Python as well.
Solution/User Experience
Just like in the TypeScript version, add a new optional parameter to the Logger initializer. For example, the new option can be called persistent_keys.
This parameter could be a simple flat dict(or similar type?), and if not provided, default to an empty dict.
The value of this new parameter could either be added to self._default_log_keys(since what ever is in that already persists through a state clearing) or be maintained separately but treated just like self._default_log_keys.
Example init:
Example storing keys:
Alternative solutions
Acknowledgment
The text was updated successfully, but these errors were encountered: