Spring Boot 添加 JFR 事件监控

Spring Boot JFR About 826 words

FlightRecorderApplicationStartup

设置ApplicationStartup

注意:不能在run之后再设置setApplicationStartup,否则无法监听启动事件。

@SpringBootApplication
public class LiteNoteApplication {

    public static void main(String[] args) {
//        SpringApplication.run(LiteNoteApplication.class, args);
        SpringApplication app = new SpringApplication(LiteNoteApplication.class);
        app.setApplicationStartup(new FlightRecorderApplicationStartup());
        app.run(args);
    }

}

启动参数

启动时需添加启动参数,才能记录Spring Boot启动的事件。

-XX:StartFlightRecording:filename=recording.jfr

日志

启动时会输出如下日志

[1.566s][info][jfr,startup] Started recording 1. No limit specified, using maxsize=250MB as default.
[1.566s][info][jfr,startup] 
[1.566s][info][jfr,startup] Use jcmd 88005 JFR.dump name=1 to copy recording data to file.

查看

JMC事件浏览器中查看Spring Application目录下的事件即可。

Views: 1,332 · Posted: 2023-02-04

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh