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
As we prepare for GA, we need to reduce the effort in creating new middlewares, and ensure any middleware is traced opt in. This would help us move faster in creating more utilities, allow customers to create their own utilities (outside of this package), and debug middleware performance as they use multiple nested options.
This feature should allow:
Decorator to create middlewares
Control before, after, handle exceptions, and whether handler should be executed if they want to
Opt in option to trace middleware as an annotation with no modification to their code
Pass data between middlewares (e.g. correlation id, cold_start, etc.)
We have to decide between two options to pass data between middlewares:
Lambda Context
Pros: Ease to extend and available between middlewares, no additional code to maintain
Cons: There could be naming collision if Lamda decides to use context more extensively, each middleware needs to handle AttributeError if key is not there
Global Stash
Pros: Available anywhere in the code and handles AttributeError if data is non existent
I'd prefer to use a global stash, separate from the Lambda context variable as the Lambda service team might want to make changes to the context that would be backward compatible with Lambda, but could break compatibility with the powertools, thus requiring work both here and for users of this library.
E.g. if this provides an additional cold_start attribute to the context, but in the future the Lambda service team decides to add that as part of the Lambda context, this would hide the original value.
In a worst case scenario, the value provided by the Lambda team could be presented differently than from powertools. E.g. if the powertools provides context.cold_start as a boolean (true/false), but then Lambda provides it as a string ("true"/"false"), "false" is a truthy value and therefore changing the behaviour in the powertools to expose the Lambda's context value would be a breaking change.
Activity
nmoutschen commentedon Apr 14, 2020
I'd prefer to use a global stash, separate from the Lambda context variable as the Lambda service team might want to make changes to the context that would be backward compatible with Lambda, but could break compatibility with the powertools, thus requiring work both here and for users of this library.
E.g. if this provides an additional
cold_startattribute to the context, but in the future the Lambda service team decides to add that as part of the Lambda context, this would hide the original value.In a worst case scenario, the value provided by the Lambda team could be presented differently than from powertools. E.g. if the powertools provides
context.cold_startas a boolean (true/false), but then Lambda provides it as a string ("true"/"false"), "false" is a truthy value and therefore changing the behaviour in the powertools to expose the Lambda's context value would be a breaking change.heitorlessa commentedon Apr 20, 2020
Now merged on 0.7.0 🎉