feat(crac): Support CRaC and priming of powertools tracing#2345
feat(crac): Support CRaC and priming of powertools tracing#2345phipag merged 22 commits intoaws-powertools:mainfrom
Conversation
|
Hey @Attyuttam, do you think you are able to develop inside Windows Subsytem for Linux (https://code.visualstudio.com/docs/remote/wsl) or inside a Docker container (https://code.visualstudio.com/docs/devcontainers/containers) or on a linux remote machine (https://code.visualstudio.com/docs/remote/remote-overview)? As a quick solution, you could also make the changes locally and then build and run the tests inside a Docker container with Java and Maven installed. What do you think? A large amount of changes you made in this PR are related to your OS (Windows) and break our Linux-based CI. Making all tests OS-independent would be task on its own. |
|
sure @phipag , I will test as you suggested. Thanks ! |
|
Hi @phipag , I’ve updated the changes and validated them in a Linux environment using WSL to match the project’s CI setup. |
phipag
left a comment
There was a problem hiding this comment.
Hey @Attyuttam,
this looks very good. Just a minor comment below and two small points:
- Can you add a unit test that asserts no exception is thrown in before and after checkpoint? Similar to this: https://github.com/aws-powertools/powertools-lambda-java/pull/2081/changes#diff-70c782dbf1e2b25496c60c4098cf6a9eb6985384319fdba0940bc9129add124b
- Let's add a no-op method such as
init()toTracingUtilsjust so that users can referenceTracingUtilswithout being forced to perform a changing operation such as adding an annotation. And after adding this, just make a small update in the documentation referencinginit()instead ofputAnnotation().
public static void init() {
// Placeholder method used to enable SnapStart priming. Users need a direct reference to this class in order for the CRaC hooks to execute.
}|
Thanks for the comments @phipag. I have incorporated them. |
|
Hey @Attyuttam, this looks good now. Thanks! One last thing: You can see that the CI for GraalVM native is failing. The reason for this is that the Mockito inline mock maker is not supported for native unit tests and it fails now since you added mockito as a dependency. To fix this, can you please add the subclass mock maker as a dependency for both GraalVM maven profiles in the powertools-lambda-java/powertools-metrics/pom.xml Lines 179 to 185 in 54fe0be powertools-lambda-java/powertools-metrics/pom.xml Lines 153 to 159 in 54fe0be |
|
|
Awesome work @Attyuttam, I just tested this and it works. Thanks for your contribution! I am looking forward to your future PRs on the issues assigned to you. As always, let me know if you have any questions. 🥳 |
Implements automatic class preloading via CRaC hooks for the idempotency-dynamodb module to improve SnapStart cold start performance. Changes: - Add ClassPreLoader.preloadClasses() call to DynamoDBPersistenceStore.beforeCheckpoint() - Generate and include classesloaded.txt with 8,726 classes - Add powertools-common dependency for ClassPreLoader - Add Maven profile generate-classesloaded-file - Add unit tests for CRaC hooks - Update Priming.md with idempotency-dynamodb example - Add null check and logging for defensive error handling This combines both invoke priming (warming DynamoDB SDK paths) and automatic priming (preloading classes) for optimal performance. Follows the same pattern as implemented in powertools-metrics (aws-powertools#1861), powertools-tracing (aws-powertools#2345), and powertools-kafka (aws-powertools#2145). Fixes aws-powertools#1997 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>



Summary
Changes
Added CRaC support in powertools-tracing, following the guide and blogs mentioned on the ticket.
Added automatic priming for powertools-metrics by preloading all the required classes, the list of classes is fetched from the JVM at compile time.
Issue number: #2004
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.