Skip to content

Add Android/Robolectric visibility to Test Optimization spans#11852

Open
daniel-mohedano wants to merge 4 commits into
masterfrom
daniel.mohedano/android-robolectric
Open

Add Android/Robolectric visibility to Test Optimization spans#11852
daniel-mohedano wants to merge 4 commits into
masterfrom
daniel.mohedano/android-robolectric

Conversation

@daniel-mohedano

@daniel-mohedano daniel-mohedano commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

  • Implements additional visibility to test spans for test emulated with the Android SDK through Robolectric. These tests are already traced OOTB as JUnit4 tests.
    • New per-test span tags:
      • test.android.api_level
      • test.android.release
      • test.android.codename
      • test.android.robolectric.version
    • New is_android_emulated boolean field on the test_event_finished telemetry metric.
  • Adds a new GradleDaemonSmokeTest test to validate the new instrumentation and tagging. It covers both @RunWith(RobolectricTestRunner.class) and @RunWith(AndroidJUnit4.class).

Motivation

With Android tests already being supported OOTB, these changes provide better visibility for customers using the Robolectric framework.

Additional Notes

test-environment-trigger: skip

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: SDTEST-3887 [SDTEST-3888] [SDTEST-3889]

@daniel-mohedano daniel-mohedano added type: feature Enhancements and improvements comp: ci visibility Continuous Integration Visibility labels Jul 3, 2026
@daniel-mohedano daniel-mohedano changed the title Report additional information for Android tests with Robolectric Add Android/Robolectric visibility to Test Optimization spans Jul 3, 2026
@datadog-datadog-us1-prod

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.02 s 13.97 s [-0.4%; +1.0%] (no difference)
startup:insecure-bank:tracing:Agent 12.91 s 13.04 s [-1.6%; -0.4%] (maybe better)
startup:petclinic:appsec:Agent 16.96 s 16.67 s [+0.6%; +2.8%] (maybe worse)
startup:petclinic:iast:Agent 16.82 s 16.99 s [-1.9%; -0.1%] (maybe better)
startup:petclinic:profiling:Agent 16.49 s 16.92 s [-3.6%; -1.4%] (significantly better)
startup:petclinic:sca:Agent 16.93 s 16.77 s [+0.0%; +1.9%] (maybe worse)
startup:petclinic:tracing:Agent 16.02 s 16.27 s [-2.6%; -0.5%] (maybe better)

Commit: 75e82e07 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@daniel-mohedano daniel-mohedano force-pushed the daniel.mohedano/android-robolectric branch from 4d4dc9e to 1b228ee Compare July 8, 2026 09:00
@daniel-mohedano daniel-mohedano marked this pull request as ready for review July 13, 2026 08:56
@daniel-mohedano daniel-mohedano requested review from a team as code owners July 13, 2026 08:56
@daniel-mohedano daniel-mohedano requested review from jordan-wong, mcculls and sarahchen6 and removed request for a team July 13, 2026 08:56

@datadog-datadog-us1-prod datadog-datadog-us1-prod Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: PASS

More details

PR adds Android/Robolectric test visibility by instrumenting TestEnvironment.setUpApplicationState() to capture SDK metadata (API level, release, codename, Robolectric version) and emit a new IsAndroidEmulated boolean metric. All defensive null checks are in place, parameter ordering to the TEST_EVENT_FINISHED metric matches the enum exactly, and the Robolectric JAR version extraction regex is correctly implemented. Test validation includes both @RunWith(RobolectricTestRunner.class) and @RunWith(AndroidJUnit4.class) runners with expected API 34 artifacts.

Was this helpful? React 👍 or 👎

📊 Validated against 7 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit 30cee80 · What is Autotest? · Any feedback? Reach out in #autotest

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30cee80829

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dd-java-agent/instrumentation/robolectric/robolectric-4.11/build.gradle Outdated
Comment thread dd-java-agent/instrumentation/robolectric/robolectric-4.11/build.gradle Outdated
@daniel-mohedano daniel-mohedano force-pushed the daniel.mohedano/android-robolectric branch from 30cee80 to 729666d Compare July 13, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: ci visibility Continuous Integration Visibility type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants