Skip to content

test(spring-boot): [Sample Tests 20] Move the Boot 3 OTel no-agent sample's tests - #6312

Draft
runningcode wants to merge 3 commits into
no/boot2-webflux-integration-testfrom
no/boot3-otel-noagent-integration-test
Draft

runningcode wants to merge 3 commits into
no/boot2-webflux-integration-testfrom
no/boot3-otel-noagent-integration-test

Conversation

@runningcode

@runningcode runningcode commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (Sample Tests)


📜 Description

Adds an integrationTestOtelNoAgent suite to sentry-spring-boot-jakarta. Here the app traces through the OpenTelemetry SDK in its own JVM, set up by sentry-opentelemetry-agentless-spring, rather than through the Java agent. The suite ports sentry-samples-spring-boot-jakarta-opentelemetry-noagent's tests:

  • Person:
    • nested spans from an OTel @WithSpan annotation, the OTel API and the Sentry API, each with its own feature flags;
    • the logged and thrown errors, and the logs;
    • the OTel db span and the profile;
    • requests with and without the sampled flag in sentry-trace.
  • DistributedTracing and Cache: the servlet suite's tests, unchanged.
  • Todo: RestTemplate and RestClient calls inside OTel and Sentry API spans, plus WebClient.
  • GraphQL: in OTel mode the task query only asserts the Query.tasks span, as the sample does.
  • Kafka coexistence: with OTel active, OTel traces both sides of a message (origin auto.opentelemetry). Sentry's own SpringKafka integration stays out. The consumer transaction is tied to the producer's trace.

The sample's MetricsSystemTest was a copy of the servlet one. It runs in this suite too, so its assertions also hold with OpenTelemetry handling the tracing.

Two problems the port surfaced:

  • The test's HTTP client was instrumented. The TestRestTemplate Spring Boot provides is a bean in the app's context, so the OTel starter instruments it. It then replaced the sentry-trace/baggage headers the tests sent with a new trace of its own, and every trace-continuation test failed. The suite uses a TestRestTemplate built outside the context instead. This is the same reason the agent tests run the app in a child JVM.
  • 5-second waits. Sentry exports OTel spans through a BatchSpanProcessor with the default 5-second schedule, which isn't configurable, so every test waited that long. MockSentryServer gets a beforeEachCheck hook that runs before each check while waiting. This suite uses it to flush the tracer provider, which took its test time from about 112s to 8s. assertNoEnvelope runs the hook too, so negative checks still mean something.

With no system tests left, the sample comes off the runner, the backend workflow and the Spring Boot 3 matrix. The matrix now runs the new suite, and integrationTests includes it too.

After a coverage audit against the sample's tests:

💡 Motivation and Context

sentry-opentelemetry-agentless-spring has no tests of its own, so this flavor is its only coverage. The suite runs 22 tests.

💚 How did you test it?

  • All 22 tests pass on Spring Boot 3.5.0.
  • They also pass with the catalog set to 3.2.12.
  • Expecting the wrong flag on the annotation span makes the test fail.
  • A temporary diagnostic confirmed the cause of the trace-continuation failures: the server continued the test client's trace, not the one in the headers. In CI, the sample's equivalent tests really run and pass.
  • MockSentryServerTest covers the new hook.
  • :sentry-test-support:check and :sentry-spring-boot-jakarta:check pass.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

The Boot 4 and Boot 2 no-agent samples.

#skip-changelog

This was referenced Oct 20, 2026
@sentry

sentry Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.61.0 (1) release

⚙️ sentry-android Build Distribution Settings

runningcode and others added 3 commits October 21, 2026 13:22
…the module

Adds an integrationTestOtelNoAgent suite to sentry-spring-boot-jakarta.
The app traces through the OpenTelemetry SDK in its own JVM, set up by
sentry-opentelemetry-agentless-spring, and the suite ports the no-agent
sample's tests: spans from the OTel annotation, the OTel API and the
Sentry API with their feature flags, the OTel database span, trace
continuation, client spans, cache spans, GraphQL, and Kafka traced by
OTel instead of Sentry's Spring Kafka integration. The sample's Metrics
tests were copies of the servlet ones and don't depend on tracing.

The suite needs a TestRestTemplate built outside the context: the one
Spring Boot provides is instrumented by the OTel starter, which replaced
the trace headers the tests send and started a new trace.

Sentry exports OTel spans in batches every 5 seconds, so every test
waited that long. MockSentryServer gets a hook that runs before each
check while waiting, which the suite uses to flush the tracer provider,
taking the suite from about 112s to 8s of test time.

The sample has no system tests left, so it comes off the system-test
runner, the backend workflow and the Spring Boot 3 matrix, which now
runs the new suite. integrationTests includes it too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nt suite

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/boot3-otel-noagent-integration-test branch from 72a8f83 to 99017bf Compare October 21, 2026 11:27
@runningcode
runningcode force-pushed the no/boot2-webflux-integration-test branch from 4aa5a32 to 38f020e Compare October 21, 2026 11:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant