Skip to content

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

Draft
runningcode wants to merge 1 commit into
no/agent-smoke-testfrom
no/agent-spring-boot-test
Draft

runningcode wants to merge 1 commit into
no/agent-smoke-testfrom
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.
  • check: the suite is wired into check for now. Whether these suites run in check or in a dedicated job gets decided after the Spring Boot pilot.

💡 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

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 12492f0 to 7cb3592 Compare October 15, 2026 14:23
@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.0 (1) release

⚙️ sentry-android Build Distribution Settings

This was referenced Oct 20, 2026

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