To make the export work at all for a native image build, it needs to be enabled during AOT processing. So we have this for the profile used for the build:
management.otlp.tracing.export.enabled: true
Now we have a native image that has the OTLP export enabled and all could be fine.
But for tests we may want to disable this if no service to export to is available.
Running the native image with management.otlp.tracing.export.enabled=false does not work so we end up with errors in the log because the export cannot connect to its target:
2025-07-30 11:46:57.877 ERROR 1 --- [.local:4318/...] i.o.exporter.internal.http.HttpExporter : Failed to export spans. The request could not be executed.
For non-native (or non-AOT) builds, runtime evaluation works as expected.
Are we missing anything or is this simply not supported? Already raised that as a question in a Stack Overflow post but got no reply.
This is with Spring 3.5.4/5 and it didn't look like anything changed in this area.
We have a workaround using a config that provides a SpanExporters bean similar to what OpenTelemetryTracingAutoConfiguration would do if the export is enabled but return it empty if it is disabled.
Comment From: mhalbritter
Hello,
this is expected and documented here. That's one of the drawbacks using AOT and native image.
Comment From: codesimplicity
this is expected and documented here. That's one of the drawbacks using AOT and native image.
Sorry to hear that. I had expected that Spring Boot wanted to provide support for AOT and native image, but your reply does not sound like that. For me the documentation of restrictions was directed to Spring Boot users. I didn't expect them to be ignored by internal Spring Boot code. No offence, just surprised about this excuse. Would have expected reasons like low prio for non trivial change.