Observability regressions under Spring Boot 4.1
Three defects from the Boot 4.1 migration, still present on top of #1808. Common cause: Boot 4 split spring-boot-actuator-autoconfigure into separate spring-boot-micrometer-* modules, and the observability module still relies on Boot 3's auto-configuration graph.
Environment: 1.5.0-SNAPSHOT, Spring Boot 4.1.0, Micrometer 1.17.0 / Tracing 1.7.0, OpenTelemetry SDK 1.62.0.
1. EmbabelMetricsEventListener is never created (all business metrics missing)
ObservabilityAutoConfiguration.java:308-316 gates the listener on @ConditionalOnBean(MeterRegistry.class), which is order-sensitive across auto-configurations. The afterName list declares ordering only against the observation and tracing auto-configurations, neither of which defines a MeterRegistry.
It worked under Boot 3 only transitively:
ObservationAutoConfiguration |
|
|---|---|
| Boot 3.5.14 | @AutoConfiguration(after = {CompositeMeterRegistryAutoConfiguration.class, MicrometerTracingAutoConfiguration.class}) |
| Boot 4.1.0 | @AutoConfiguration, no after at all |
Boot 4 split observation and metrics into separate modules, so that edge is gone. The MeterRegistry now comes from …micrometer.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration and the export.* registries, none reachable from afterName. Without an explicit edge the sorter falls back to alphabetical order, so com.embabel.… runs before org.springframework.… and the condition sees no registry.
#1808 fixed the afterName FQCNs correctly; the problem is that the list is now incomplete.
Fix: replace @ConditionalOnBean(MeterRegistry.class) with a lazily resolved ObjectProvider<MeterRegistry>, the pattern the module already applies to the Tracer in MicrometerTracingAutoConfiguration.java:80-94, for exactly this reason.
2. Every span is exported twice
OpenTelemetrySdkAutoConfiguration.java:119-127 registers span processors from two sources:
for (SpanProcessor processor : validProcessors) // all SpanProcessor beans
tracerProviderBuilder.addSpanProcessor(processor);
for (SpanExporter exporter : validExporters) // all SpanExporter beans, wrapped again
tracerProviderBuilder.addSpanProcessor(BatchSpanProcessor.builder(exporter).build());
Since spring-boot-micrometer-tracing-opentelemetry was added to embabel-agent-starter-observability (part of the #1808 fix), Boot's OpenTelemetryTracingAutoConfiguration now contributes an otelSpanProcessor bean that already wraps all SpanExporter beans via CompositeSpanExporter. Embabel consumes it and wraps each exporter a second time:
spanProcessorsAll=[
BatchSpanProcessor{spanExporter=io.micrometer.tracing.otel.bridge.CompositeSpanExporter@…},
BatchSpanProcessor{spanExporter=<the application's SpanExporter bean>}]
Result: duplicated traces and doubled exporter volume in Langfuse / Zipkin / OTLP.
@ConditionalOnEnabledTracingExport guards only the OTLP/Zipkin exporter and propagation configurations, not otelSpanProcessor:
| Configuration | Exports per span |
|---|---|
| (none) | 2 |
management.tracing.enabled=false |
2 |
management.tracing.export.enabled=false |
2 |
management.tracing.sampling.probability=0.0 |
2 |
management.opentelemetry.enabled=false |
1 |
Fix: skip the per-exporter loop when any SpanProcessor bean is present, or gate sdkTracerProvider on @ConditionalOnMissingBean(SpanProcessor.class) and let Boot own the provider.
3. Dead tracing configuration
management.tracing.enabled is no longer bound. Boot 4 metadata marks it "deprecation": {"level": "error", "replacement": "management.tracing.export.enabled", "since": "4.0.0"}. It is still shipped in embabel-agent-api/src/main/resources/agent-application.properties:21 (main resources, loaded for every consumer via @PropertySource in AgentPlatformPropertiesLoader.kt:60), plus test resources and the docs. Under Boot 3 it disabled Boot's tracing chain; under Boot 4 that stack now activates by default everywhere.
management.tracing.sampling.probability has no effect. The docs tell users to set it (README.md:1311), but Boot's otelSampler bean is only consumed by Boot's otelSdkTracerProvider, which backs off in favour of Embabel's. sdkTracerProvider never calls setSampler, so the sampler is always ParentBased{root:AlwaysOnSampler,…}, confirmed by the last row above.
Fix: correct the property key, and either wire the Sampler bean into sdkTracerProvider or drop the knob from the docs.