Skip to content

Spring Boot Starter does not flush telemetry on shutdown #14110

@jasperkamerling

Description

@jasperkamerling

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageNew issue that requires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions