Skip to content

Support Spring Boot 3 format #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.idea/
/build/
/.gradle/
/converter-spring-boot-startup.jar
/converter.jar
/reports/
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,30 @@ public class App {
}
```

If you have this project cloned, you can run `./capture.sh name` which will fetch the startup json, collapse it, and generate an html report named `name`. If necessary, it will also build this project and download async-profiler jar,

#### Download startup json

```shell
curl localhost:8091/actuator/startup > startup.json
curl localhost:8080/actuator/startup > startup.json
```

#### Download spring-startup-to-collapse-stack converter
```shell
curl -L https://github.com/wyhasany/spring-startup-to-collapse-stack/releases/download/0.1-alpha/converter-spring-boot-startup.jar --output converter-spring-boot-startup.jar
curl -L https://github.com/wyhasany/spring-startup-to-collapse-stack/releases/download/0.2-alpha/converter-spring-boot-startup.jar --output converter-spring-boot-startup.jar
```

#### Convert `startup.json` to collapse format

Keep in mind to use JDK 16
Keep in mind to use JDK 17
```shell
java -jar converter-spring-boot-startup.jar startup.json startup.collapse
```

#### Convert collapse format to HTML 5 Flame Graph
```shell
# Download async-profiler's converter
curl -L https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.5/converter.jar --output converter.jar
curl -L https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.9/converter.jar --output converter.jar
# convert to flame graph
java -cp converter.jar FlameGraph startup.collapse output.html
```
Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'com.github.johnrengelman.shadow' version "8.1.1"
id 'java'
}

group 'com.github.wyhasany'
version '1.0-SNAPSHOT'
version '0.2'

repositories {
mavenCentral()
}

dependencies {
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
testImplementation 'org.assertj:assertj-core:3.21.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation libs.bundles.jackson

testImplementation libs.test.assertj.core
testImplementation libs.test.junit.api
testRuntimeOnly libs.test.junit.engine
}

task testJar(type: Jar) {
Expand Down
21 changes: 21 additions & 0 deletions capture.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail

PROFILE_NAME=${1}

if [ ! -d "reports" ]; then
mkdir reports
fi

curl --fail-with-body localhost:8080/actuator/startup > "reports/$PROFILE_NAME.json"

if [ ! -f "converter-spring-boot-startup.jar" ]; then
./gradlew shadowJar
cp build/libs/converter-spring-boot-startup.jar .
fi
java -jar converter-spring-boot-startup.jar "reports/$PROFILE_NAME.json" "reports/$PROFILE_NAME.collapse"

if [ ! -f "converter.jar" ]; then
curl -L https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.9/converter.jar --output converter.jar
fi
java -cp converter.jar FlameGraph "reports/$PROFILE_NAME.collapse" "reports/$PROFILE_NAME.html"
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading