generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Labels
feature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilitymetricsThis item relates to the Metrics UtilityThis item relates to the Metrics Utility
Description
Use case
The InvokeStore
pacakge, allow for the use of Asynchronous contexts in lambda handlers. We should allow users to set metrics in async contexts across lambda executions so that they are isolated.
Solution/User Experience
Lambda handlers in the runtime are automatically wrapped in this context, this can be replicated locally like so:
export const handler = async (event, context) => {
// This metadata with this userId will be scoped only to this handler execution and will not be available in any other invocations
metrics.addMetadata("userId", event.userId);
return {
requestId: InvokeStore.getRequestId(),
userId,
};
};
// ...
const result = InvokeStore.run(
{
[InvokeStore.PROTECTED_KEYS.REQUEST_ID]: "request-123",
[InvokeStore.PROTECTED_KEYS.X_RAY_TRACE_ID]: "trace-456", // Optional X-Ray trace ID
customField: "value", // Optional custom fields
},
() => {
return handler(event)
}
);
Alternative solutions
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
feature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilitymetricsThis item relates to the Metrics UtilityThis item relates to the Metrics Utility
Type
Projects
Status
Working on it