Add observability: real OTLP metrics/traces to grafana/otel-lgtm, Docker Compose auto-wiring, and a dual-version (Boot 4.0 vs 4.1) proof of the new OTEL_* env var support
Companion module for the rewritten ankurm.com Prometheus/Grafana monitoring post. Verified against a real running grafana/otel-lgtm container (not mocked): 8 real requests produce a real orders_placed_total metric queried back from the bundled Prometheus-compatible API with zero management.otlp.* properties, auto-wired entirely by Boot's Docker Compose service-connection detection. Two real findings surfaced along the way and documented rather than smoothed over: @Observed silently produces no span without an explicit ObservedAspect bean (AspectJ weaving alone is not sufficient, despite Micrometer Tracing being active), and OTEL_EXPORTER_OTLP_ENDPOINT already worked on Boot 4.0 via Micrometer's own OtlpConfig fallback -- what's actually new in 4.1 is the rest of the standard OTEL_* surface (verified with OTEL_METRIC_EXPORT_INTERVAL against identical source compiled on both Boot 4.0.8 and 4.1.1). Also fixes the root README's module table, which was missing a row for resilience4j-circuit-breaker (added in a previous commit but never indexed here).
This commit is contained in:
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# Rebuilds and runs the env-var-proof/boot40 vs boot41 experiment described in
|
||||
# docs/03-otel-env-vars.md, and regenerates docs/output/04-otel-env-vars-4.0-vs-4.1.txt.
|
||||
# Requires JDK 25 and network access (each module resolves its own Boot parent POM).
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
ROOT="$(pwd)"
|
||||
|
||||
mkdir -p env-var-proof/stub-receiver/out
|
||||
javac env-var-proof/stub-receiver/StubOtlpReceiver.java -d env-var-proof/stub-receiver/out
|
||||
|
||||
(cd env-var-proof/boot40 && mvn -q -DskipTests package)
|
||||
(cd env-var-proof/boot41 && mvn -q -DskipTests package)
|
||||
|
||||
run_case() {
|
||||
local label="$1" jar="$2" port="$3"
|
||||
shift 3
|
||||
local log="/tmp/otel-proof-${label}.log"
|
||||
rm -f "$log"
|
||||
java -cp env-var-proof/stub-receiver/out StubOtlpReceiver "$port" "$log" &
|
||||
local receiver_pid=$!
|
||||
sleep 1
|
||||
echo "=== $label ==="
|
||||
env "$@" timeout 30 java -jar "$jar" | grep -E "Publishing metrics" || true
|
||||
kill "$receiver_pid" 2>/dev/null || true
|
||||
echo "--- receiver log ($label) ---"
|
||||
cat "$log"
|
||||
}
|
||||
|
||||
run_case "boot41-env-vars" "env-var-proof/boot41/target/otel-env-proof-41-1.0.0.jar" 24318 \
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:24318" OTEL_METRIC_EXPORT_INTERVAL=2000
|
||||
run_case "boot40-env-vars" "env-var-proof/boot40/target/otel-env-proof-40-1.0.0.jar" 24319 \
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:24319" OTEL_METRIC_EXPORT_INTERVAL=2000
|
||||
run_case "boot40-management-props" "env-var-proof/boot40/target/otel-env-proof-40-1.0.0.jar" 24320 \
|
||||
MANAGEMENT_OTLP_METRICS_EXPORT_URL="http://localhost:24320/v1/metrics" MANAGEMENT_OTLP_METRICS_EXPORT_STEP=2s
|
||||
|
||||
echo "Compare the three receiver logs above against docs/output/04-otel-env-vars-4.0-vs-4.1.txt"
|
||||
Reference in New Issue
Block a user