Skip to content

test(otel): [Sample Tests 4] Add a smoke test for the built agent - #6269

Open
runningcode wants to merge 1 commit into
no/shared-envelope-matchersfrom
no/agent-smoke-test
Open

runningcode wants to merge 1 commit into
no/shared-envelope-matchersfrom
no/agent-smoke-test

Conversation

@runningcode

@runningcode runningcode commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (Sample Tests)


📜 Description

Adds AgentSmokeTest, the first test in sentry-opentelemetry-agent. It:

  1. launches a JDK-only HelloServer in a child JVM with the built agent attached (-javaagent);
  2. sends one request to it;
  3. asserts that an http.server transaction with SDK name sentry.java.opentelemetry.agent reaches MockSentryServer.

The test task gets the agent jar through a CommandLineArgumentProvider with an @InputFile. So the task depends on shadowJar and reruns whenever the jar changes. The current systemTest convention only tracks a hardcoded path.

Why a child JVM: attaching the agent to the Gradle test JVM would also instrument the test itself:

  • the test's HTTP client, overwriting the sentry-trace/baggage headers that the distributed-tracing tests set;
  • MockSentryServer. Agent 2.29 instruments com.sun.net.httpserver, so every envelope POST would become a transaction that gets posted again.

Adding Kotlin for the test enrolls the module in API validation, hence the new .api file listing AgentMarker. Every sibling OTel module with Kotlin already has one.

💡 Motivation and Context

The agent had no in-module tests. Only three samples × two auto-init modes covered it, in a non-blocking CI job. This test catches a broken agent jar (manifest, relocation, SDK name, instrumentation loading) in :sentry-opentelemetry:sentry-opentelemetry-agent:test.

It also proves the child-JVM approach that the agent samples' tests will use when they move into modules. It costs about 6.5s.

💚 How did you test it?

  • The test passes in about 6.5s. The child's output ends up in the test report's system-out.
  • Asserting a different SDK name makes it fail.
  • :sentry-opentelemetry:sentry-opentelemetry-agent:check passes.

📝 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

Move the launcher into sentry-test-support and run a Spring Boot fixture under the agent with SENTRY_AUTO_INIT=true and false. Then port the agent samples' tests: Boot 2/3/4 × auto-init on/off.

#skip-changelog

@runningcode runningcode changed the title test(otel): [Sample Tests 4] Smoke-test the built agent in a child JVM test(otel): [Sample Tests 4] Add a smoke test for the built agent Oct 15, 2026
@runningcode
runningcode marked this pull request as ready for review October 15, 2026 13:47
The agent had no tests; only the sample system tests exercised it. The
test launches a JDK-only app in a child JVM with the agent attached and
asserts that an incoming request reaches MockSentryServer as an
http.server transaction from the agent SDK.

The app runs in a child JVM so the test's own JVM stays uninstrumented.
Otherwise the agent would turn the test's HTTP calls and the mock server
into spans. The agent jar is wired as a test input, so the test reruns
whenever the jar changes.

Adding Kotlin for the test enrolls the module in API validation, hence
the new API dump.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/shared-envelope-matchers branch from 47c6edc to cf186ed 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 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