Skip to content

test(otel): [Sample Tests 5] Test a Spring Boot app under the agent - #6271

Merged
runningcode merged 1 commit into
mainfrom
no/agent-spring-boot-test
Oct 22, 2026
Merged

runningcode merged 1 commit into
mainfrom
no/agent-spring-boot-test

Conversation

@runningcode

@runningcode runningcode commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (Sample Tests)


📜 Description

Adds OtelAgentPersonTest in a new integrationTestOtelAgent test suite in sentry-spring-boot-jakarta. It runs a Spring Boot app with the built agent in a child JVM, requests an endpoint that fails, and checks what reaches MockSentryServer:

  • the logged error and the thrown exception, both with their feature flag;
  • the http.server transaction, with spans created through both the OTel API and the Sentry API;
  • Sentry logs and their attributes.

The test runs twice:

SENTRY_AUTO_INIT Who initializes Sentry SDK name in the envelope header
true the agent sentry.java.opentelemetry.agent
false the Spring Boot starter sentry.java.spring-boot.jakarta

Different SDK names show that each mode really takes its own init path.

How the pieces fit:

  • ChildJvmApp (sentry-test-support): the launcher, moved out of AgentSmokeTest. Apps write their port to the file named by PORTFILE. Spring Boot's WebServerPortFileWriter already supports that, so the Boot app needs no custom code for it.
  • ChildJvmTestArguments (build-logic): passes the agent jar and the app classpath to the test JVM as task inputs. It replaces the class that was defined inline in the agent module's build script.
  • agentFixture source set: the app has its own source set, so it runs on a classpath like a real app with the agent attached. The test classpath wouldn't work: it has mocks, Truth, and the agent's plain jar, whose AgentMarker would flip the auto-configuration conditions.
  • Agent jar: resolved through a configuration that selects the shadowed variant, so Gradle builds the jar before the suite runs.
  • CI: the suite isn't part of check. test(spring-boot): [Sample Tests 6] Move the Boot 3 Person test into the module #6292 adds it to the Spring Boot 3 matrix; until then, CI doesn't run it.

💡 Motivation and Context

In the agent samples' CI, the auto-init=false variant has the same task inputs as the true variant, so Gradle can skip it as up to date. This PR checks both modes in-module, at about 8s each. That unblocks moving the agent samples' tests into the Boot modules.

The sample's PersonSystemTest stays until the rest of the agent sample's tests move.

💚 How did you test it?

  • Both tests pass locally in about 8s each. Most of that is the agent's 5s span export interval.
  • :sentry-test-support:check, :sentry-opentelemetry:sentry-opentelemetry-agent: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

  1. Move the rest of the jakarta agent sample's tests into this suite and delete them from the sample: creating a person with JDBC, trace headers, GraphQL, and Kafka coexistence.
  2. Do the same for Boot 4 and Boot 2.

#skip-changelog

@sentry

sentry Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

This was referenced Oct 20, 2026
@runningcode
runningcode force-pushed the no/agent-spring-boot-test branch 2 times, most recently from 5e6b6d2 to b6735fe Compare October 21, 2026 11:27
@runningcode
runningcode force-pushed the no/agent-spring-boot-test branch from b6735fe to dc154c2 Compare October 22, 2026 12:40
Base automatically changed from no/agent-smoke-test to main October 22, 2026 13:26
@runningcode
runningcode force-pushed the no/agent-spring-boot-test branch from dc154c2 to 96b0caf Compare October 22, 2026 13:27
Runs a Spring Boot app with the built agent in a child JVM and checks
that errors, the server transaction with OTel and Sentry API spans, and
logs reach MockSentryServer. It runs once with the agent initializing
Sentry and once with the Spring Boot starter doing it; the SDK name
proves which path ran. The sample's auto-init=false CI variant shares
task inputs with the true variant, so Gradle can skip it as up to date.

The app has its own source set so it runs on an app-like classpath
rather than the test's, which carries the agent's plain jar and would
flip the auto-configuration conditions.

The child-JVM launcher moves into sentry-test-support and the argument
provider into build-logic, so both agent tests share them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/agent-spring-boot-test branch from 96b0caf to c518635 Compare October 22, 2026 14:02
@runningcode
runningcode marked this pull request as ready for review October 22, 2026 14:10
@runningcode runningcode added the ship-it PR is ready to merge from a reviewer perspective label Oct 22, 2026
@runningcode
runningcode merged commit c2e5997 into main Oct 22, 2026
70 of 74 checks passed
@runningcode
runningcode deleted the no/agent-spring-boot-test branch October 22, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ship-it PR is ready to merge from a reviewer perspective

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants