-
Notifications
You must be signed in to change notification settings - Fork 973
Description
Describe the bug
When using the Spring Boot Starter to configure the OTEL SDK telemetry data is not flushed before shutting down. This does happen when using the byte buddy java agent, see io.opentelemetry.javaagent.tooling.OpenTelemetryInstaller#installOpenTelemetrySdk
Only the flush on the otlp http exporter is called (eg OtlpHttpLogRecordExporter#flush
) but that does not actually flush the in memory data.
Steps to reproduce
- Set up a Spring Boot repo with the
opentelemetry-spring-boot-starter
dependency but without spring-web - Startup the application (it should stop after a couple seconds)
- The logs should be exported to localhost now but that does not happen
- If no tooling is running locally you should see failed http calls but that is not the case here.
Example repo: https://github.com/jasperkamerling/no-flush-demo
Expected behavior
Metrics, Traces and logs are flushed before shutting down
Actual behavior
Metrics, traces and logs are not flushed when shutting down the application. Leading to a loss of data.
Javaagent or library instrumentation version
2.17.0
Environment
JDK: 21.0.7
OS: Ubuntu 24.10
Additional context
We run a small Java job that starts up and shuts down several seconds later. Because the data is not flushed before shutdown we don't see any logs or metrics data.
I tried writing the code to fix this but I simply lack the knowledge of the OTEL framework to do this properly. If I can assist in any way please let me know.