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).
44 lines
2.0 KiB
Plaintext
44 lines
2.0 KiB
Plaintext
Identical Java source (env-var-proof/OtelEnvProofApplication.java), compiled twice against two
|
|
different spring-boot-starter-parent versions -- 4.0.8 and 4.1.1 -- run with ONLY standard OTEL_*
|
|
environment variables set (zero management.otlp.* Spring properties anywhere), against a
|
|
minimal stand-in OTLP receiver that just logs every POST it gets:
|
|
|
|
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:PORT
|
|
OTEL_METRIC_EXPORT_INTERVAL=2000
|
|
|
|
--- Spring Boot 4.1.1 ---
|
|
|
|
Publishing metrics for OtlpMeterRegistry every 2s to http://localhost:PORT/v1/metrics ...
|
|
|
|
receiver log (20s window):
|
|
... POST /v1/metrics content-length=8247 (x11, one every ~2s)
|
|
|
|
Both the endpoint AND the interval standard env vars were honored.
|
|
|
|
--- Spring Boot 4.0.8, same two env vars ---
|
|
|
|
Publishing metrics for OtlpMeterRegistry every 1m to http://localhost:PORT/v1/metrics ...
|
|
|
|
receiver log (20s window):
|
|
... POST /v1/metrics content-length=8247 (x1, at JVM shutdown only)
|
|
|
|
The endpoint env var was honored (Micrometer's own OtlpConfig has long fallen back to
|
|
OTEL_EXPORTER_OTLP_ENDPOINT independent of Spring Boot's own property binding). The interval
|
|
env var was NOT -- the exporter still logs "every 1m", the JVM's own default, and the only POST
|
|
the receiver saw was the one every PushMeterRegistry fires on shutdown regardless of interval.
|
|
|
|
--- Spring Boot 4.0.8, old-style Spring property instead ---
|
|
|
|
MANAGEMENT_OTLP_METRICS_EXPORT_URL=http://localhost:PORT/v1/metrics
|
|
MANAGEMENT_OTLP_METRICS_EXPORT_STEP=2s
|
|
|
|
Publishing metrics for OtlpMeterRegistry every 2s to http://localhost:PORT/v1/metrics ...
|
|
|
|
receiver log (20s window):
|
|
... POST /v1/metrics content-length=8435 (x11, one every ~2s)
|
|
|
|
Boot 4.0's own management.otlp.* properties always worked for this. What's new in 4.1 is that
|
|
the SAME standard OTEL_* variable now works too, without a Spring-specific property to learn --
|
|
useful the moment the same env vars are already used to configure something else in the same
|
|
deployment (the OTel Collector, another language's service, docker-compose.yml).
|