Skip to content

feat: Support CRaC and priming of powertools logging - #2605

Open
David-DAM wants to merge 3 commits into
aws-powertools:mainfrom
David-DAM:feature/support_crac_on_powertools_logging
Open

feat: Support CRaC and priming of powertools logging#2605
David-DAM wants to merge 3 commits into
aws-powertools:mainfrom
David-DAM:feature/support_crac_on_powertools_logging

Conversation

@David-DAM

@David-DAM David-DAM commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Issue number: Closes #2001

Description of changes:

  • Added CRaC support in powertools-logging, following the guide and blogs mentioned on the ticket.
  • Added automatic priming for powertools-logging by preloading all the required classes, the list of classes is fetched from the JVM at compile time.

Checklist

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@David-DAM David-DAM changed the title feat: Support CRaC and priming of powertools batch- #2590 feat: Support CRaC and priming of powertools logging Aug 9, 2026
@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2026

Copy link
Copy Markdown

@David-DAM

Copy link
Copy Markdown
Contributor Author

Hi @phipag I have tested the changes in my own AWS account, below you can find the code and logs that i have used to test this changes

package com.davinchicoder;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.lambda.powertools.logging.PowertoolsLogging;

import java.util.Map;

/**
 * Lambda function entry point. You can change to use other pojo type or implement
 * a different RequestHandler.
 *
 * @see <a href=https://docs.aws.amazon.com/lambda/latest/dg/java-handler.html>Lambda Java Handler</a> for more information
 */
public class App implements RequestHandler<Map<String, String>, String> {

    private static final Logger log = LoggerFactory.getLogger(App.class);

    static {
        log.info("Static initializer");
        PowertoolsLogging.init();
    }

    public App() {
        log.info("Constructor");
    }

    @Override
    public String handleRequest(Map<String, String> input, Context context) {
        return PowertoolsLogging.withLogging(context, () -> {

            log.info("Handling request");

            return "OK";
        });
    }
}
2026-08-09T08:00:01.160Z
INIT_START Runtime Version: java:21.mainline.v80 Runtime Version ARN: arn:aws:lambda:eu-west-3::runtime:8dee5610caeca919f0d5a76f2750ab61a125e33d6e3ca2757239cf7c06e3bed3
2026-08-09T08:00:03.280Z
08:00:03.261 [main] INFO com.davinchicoder.App - Static initializer
2026-08-09T08:00:03.341Z
08:00:03.340 [main] INFO com.davinchicoder.App - Constructor
2026-08-09T08:00:06.861Z
08:00:06.860 [main] DEBUG s.a.l.p.c.internal.ClassPreLoader - SnapStart priming: preloaded 3520 class(es) from classesloaded.txt
2026-08-09T08:00:06.945Z
INIT_REPORT Init Duration: 5785.33 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Priming for powertools-logging

1 participant