Skip to content

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

Merged
phipag merged 10 commits into
aws-powertools:mainfrom
David-DAM:feature/support_crac_on_powertools_logging
Oct 8, 2026
Merged

phipag merged 10 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
@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

@sonarqubecloud

Copy link
Copy Markdown

@David-DAM

Copy link
Copy Markdown
Contributor Author

@phipag Could you please review this PR?

@David-DAM
David-DAM requested a review from a team as a code owner October 6, 2026 15:38
@David-DAM
David-DAM requested a review from dreamorosi October 6, 2026 15:38

@phipag phipag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding SnapStart priming to the logging module, @David-DAM. The CRaC registration follows the same pattern as tracing and large messages. I left two comments to address before we merge.

Comment thread docs/core/logging.md Outdated
@David-DAM
David-DAM requested a review from phipag October 7, 2026 13:52
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

@phipag phipag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @David-DAM for your contribution, again!

@mergify

mergify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@phipag
phipag merged commit b66b7ad into aws-powertools:main Oct 8, 2026
14 checks passed
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

2 participants