#!/usr/bin/env bash # Boots with BufferingApplicationStartup, then dumps the step tree three ways: # self time by phase, slowest steps by self time, and the same list by total time # (which is what /actuator/startup would have you sort by). set -uo pipefail source "$(dirname "$0")/env.sh" "$(dirname "$0")/stop.sh" "$JAVA_HOME/bin/java" -Dstartup.tracking=buffering -jar "$JAR" > /tmp/startup-app.log 2>&1 & PID=$! for _ in $(seq 1 180); do curl -fs -o /dev/null localhost:8080/actuator/health && break; sleep 0.5; done echo "=== Boot's own startup line ===" grep -h 'Started StartupDiagnosisApplication' /tmp/startup-app.log | sed 's/^.*: //' echo echo "=== /diag/startup ===" curl -s 'localhost:8080/diag/startup?top=12' > /tmp/diag.json python3 - <<'PY' import json d = json.load(open('/tmp/diag.json')) print(f"recorded steps: {d['recordedSteps']}\n") print("-- self time by step name (self = duration minus direct children) --") print(f"{'self ms':>9} {'count':>5} step") for r in d['phasesBySelfTime']: print(f"{r['selfMs']:9.2f} {r['count']:5d} {r['step']}") def bean(t): return t.get('beanName') or t.get('classNames') or '' print("\n-- slowest individual steps by SELF time (the culprits) --") print(f"{'self ms':>9} {'total ms':>9} step / tags") for r in d['slowestBySelfTime']: print(f"{r['selfMs']:9.2f} {r['totalMs']:9.2f} {r['name']} {bean(r['tags'])}") print("\n-- slowest individual steps by TOTAL time (the containers) --") print(f"{'total ms':>9} {'self ms':>9} step / tags") for r in d['slowestByTotalTime']: print(f"{r['totalMs']:9.2f} {r['selfMs']:9.2f} {r['name']} {bean(r['tags'])}") PY echo echo "=== actuator's own endpoint: GET peeks, POST drains ===" for verb in GET POST POST GET; do n=$(curl -s -X $verb localhost:8080/actuator/startup \ | python3 -c "import sys,json;print(len(json.load(sys.stdin).get('timeline',{}).get('events',[])))" 2>/dev/null || echo "-") echo " $verb /actuator/startup -> events in response: $n" done kill -9 $PID 2>/dev/null wait $PID 2>/dev/null true