Skip to content

Make JFR-based observability opt-in - #5524

Open
fabiomolignoni wants to merge 1 commit into
spring-projects:mainfrom
fabiomolignoni:GH-5326
Open

fabiomolignoni wants to merge 1 commit into
spring-projects:mainfrom
fabiomolignoni:GH-5326

Conversation

@fabiomolignoni

Copy link
Copy Markdown
Contributor

Fixes #5326.

Spring Batch currently instantiates JFR events directly, causing NoClassDefFoundError when running on minimized Java runtimes without the jdk.jfr module.

This change introduces a JFR-independent BatchEventRecorder abstraction with a no-op default implementation. FlightRecorderBatchEventRecorder provides explicit JFR activation, with recorder configuration supported through the application context, builders, and setters.
This follows the same opt-in approach as Spring Framework's ApplicationStartup infrastructure, which uses a no-op implementation by default and provides FlightRecorderApplicationStartup for explicitly enabling JFR startup events.
Existing batch event instrumentation delegates to the new abstraction, and the documentation explains how to enable JFR recording.

Validation:

  • Added unit tests for the no-op recorder, JFR event factories, recorder injection, and job launch recording.
  • Manually verified that tasklet and chunk jobs complete with jdk.jfr unavailable.
  • Manually verified that explicit JFR activation produces recorded batch events.

Signed-off-by: Fabio Molignoni <fabiomolignoni@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java.lang.ClassNotFoundException: jdk.jfr.Event with minimized JRE

1 participant