#!/usr/bin/env bash # The jlink image built from jdeps' module list alone runs fine - and exports fewer metrics. # Diffs /actuator/prometheus metric names against the full-JRE image. -> docs/output/jlink-metrics.txt set -uo pipefail source "$(dirname "$0")/env.sh" names() { local name="jl-$$-$2" docker rm -f "$name" > /dev/null 2>&1 docker run -d --name "$name" -p "$2:8080" "$1" > /dev/null for _ in $(seq 1 300); do curl -s -o /dev/null "localhost:$2/actuator/health" && break; sleep 0.1; done curl -s -o /dev/null "localhost:$2/api/items" curl -s "localhost:$2/actuator/prometheus" | grep -v '^#' | sed 's/[{ ].*//' | sort -u docker logs "$name" 2>&1 | grep -E ' WARN ' | sed 's/^.* WARN [0-9]* --- \[[^]]*\] \[ *[^]]*\] //' >&2 docker rm -f "$name" > /dev/null } { echo "# jlink modules chosen by jdeps alone:" docker run --rm --entrypoint /opt/jre/bin/java sbd/docker-images:jlink-jdeps-only --list-modules | sed 's/@.*//' | tr '\n' ' '; echo echo echo "# WARN lines at startup of the jdeps-only image:" names sbd/docker-images:jlink-jdeps-only 18101 2>&1 >/tmp/jl-a.txt | sed 's/^/ /' names sbd/docker-images:layered-distroless 18102 2>/dev/null > /tmp/jl-b.txt names sbd/docker-images:jlink-distroless 18103 2>/dev/null > /tmp/jl-c.txt echo echo "# Metric names: full JRE $(wc -l < /tmp/jl-b.txt), jdeps-only $(wc -l < /tmp/jl-a.txt), jdeps + jdk.management $(wc -l < /tmp/jl-c.txt)" echo "# Present with the full JRE, missing from the jdeps-only image:" comm -23 /tmp/jl-b.txt /tmp/jl-a.txt | sed 's/^/ /' echo "# Missing from jdeps + jdk.management: $(comm -23 /tmp/jl-b.txt /tmp/jl-c.txt | wc -l)" comm -23 /tmp/jl-b.txt /tmp/jl-c.txt | sed 's/^/ /' echo "# (jvm_gc_concurrent_phase_time_* is registered lazily, after the first G1 concurrent cycle -" echo "# whether it appears within a few seconds of startup varies run to run, in either image.)" } | tee "$OUT/jlink-metrics.txt"