Skip to content

Migrate dd-trace-core groovy files to java part 13 - #12253

Open
jpbempel wants to merge 3 commits into
masterfrom
jpbempel/g2j-core-pt13
Open

Migrate dd-trace-core groovy files to java part 13#12253
jpbempel wants to merge 3 commits into
masterfrom
jpbempel/g2j-core-pt13

Conversation

@jpbempel

@jpbempel jpbempel commented Aug 21, 2026

Copy link
Copy Markdown
Member

What Does This Do

we migrate 17 tests:

  • ConflatingMetricAggregatorTest
  • FootprintForkedTest
  • MetricsAggregatorFactoryTest
  • MetricsReliabilityTest
  • OkHttpSinkTest
  • SerializingMetricWriterTest
  • AllSamplerTest
  • AsmStandaloneSamplerTest
  • DeterministicSpanSamplerTest
  • DeterministicTraceSamplerTest
  • ForcePrioritySamplerTest
  • RateByServiceTraceSamplerTest
  • RuleBasedSamplingTest
  • SamplerTest
  • SingleSpanSamplerTest
  • SpanSamplingRulesTest
  • TraceSamplingRulesTest

Motivation

this is part of the effort to migrate groovy tests to Java/JUnit
part1: #11053
part2: #11062
part3: #11085
part4: #11146
part5: #11217
part6: #11362
part7: #11374
part8: #11437
part9: #11488
part10: #11543
part11: #11566
part12: #11619

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

we migrate 17 tests:
 - ConflatingMetricAggregatorTest
 - FootprintForkedTest
 - MetricsAggregatorFactoryTest
 - MetricsReliabilityTest
 - OkHttpSinkTest
 - SerializingMetricWriterTest
 - AllSamplerTest
 - AsmStandaloneSamplerTest
 - DeterministicSpanSamplerTest
 - DeterministicTraceSamplerTest
 - ForcePrioritySamplerTest
 - RateByServiceTraceSamplerTest
 - RuleBasedSamplingTest
 - SamplerTest
 - SingleSpanSamplerTest
 - SpanSamplingRulesTest
 - TraceSamplingRulesTest
@jpbempel
jpbempel requested a review from a team as a code owner August 21, 2026 09:21
@jpbempel
jpbempel requested review from jandro996 and removed request for a team August 21, 2026 09:21
@dd-octo-sts

dd-octo-sts Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@jpbempel jpbempel added comp: testing Testing tag: no release notes Changes to exclude from release notes type: refactoring labels Aug 21, 2026
@datadog-datadog-us1-prod

This comment has been minimized.

@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: 37bcdd17fc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


// writer should be reset if reporting fails
assertTrue(latchTriggered);
verify(writer, atLeastOnce()).startBucket(anyInt(), anyLong(), anyLong());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the exact serialization-failure call count

If the reporting loop invokes startBucket more than once after this serialization error, atLeastOnce() still passes, whereas the migrated Spock interaction required exactly one invocation. This weakens the test so repeated failing writes or retries can regress unnoticed; retain the original cardinality with times(1).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

Collections.singletonList(
new SimpleSpan("", "", "", "", false, false, false, 0, 0, HTTP_OK)));

clearInvocations(sink);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear sink invocations before publishing

With the 1 ms reporting interval, the scheduled reporter can process this trace after publish but before clearInvocations; the clear then erases the unexpected sink call, and the subsequent forced report is empty, so verifyNoInteractions passes even if an unmeasured trace was incorrectly reported. Move the clear before publish, as the following test already does.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

long after = footprint(aggregator, features);
assertTrue(after - baseline <= 10L * 1024 * 1024, "footprint growth exceeds 10MB");

aggregator.close();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Close the footprint aggregator on assertion failures

When the acknowledged-flaky footprint assertion or either preceding timeout fails, execution never reaches this close, whereas the original Spock cleanup block always ran. Because start() launches an aggregator thread and scheduled reporter and this table has six invocations in the same test JVM, the leaked instance can continue running and interfere with later footprint cases; put the lifecycle in a try/finally.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

@dd-octo-sts

dd-octo-sts Bot commented Aug 21, 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.81 s 14.71 s [-0.1%; +1.5%] (no difference)
startup:insecure-bank:tracing:Agent 13.61 s 13.69 s [-1.5%; +0.3%] (no difference)
startup:petclinic:appsec:Agent 16.89 s 16.57 s [+1.0%; +2.7%] (significantly worse)
startup:petclinic:iast:Agent 16.89 s 16.96 s [-1.2%; +0.3%] (no difference)
startup:petclinic:profiling:Agent 16.77 s 16.38 s [-2.0%; +6.8%] (no difference)
startup:petclinic:sca:Agent 16.74 s 16.59 s [-0.0%; +1.8%] (no difference)
startup:petclinic:tracing:Agent 15.69 s 15.11 s [-4.5%; +12.2%] (unstable)

Commit: 6d857f0b · 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.

@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: FAIL

The Java migration weakens one exact call-count check. A repeated startBucket call now passes in the serialization-error test, but the old Groovy test rejects it.

Open Bits AI session

🤖 Datadog Autotest · Commit 37bcdd1 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest


// writer should be reset if reporting fails
assertTrue(latchTriggered);
verify(writer, atLeastOnce()).startBucket(anyInt(), anyLong(), anyLong());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Keep the exact startBucket call count

A later retry defect can reach production because this test no longer rejects repeated failed bucket starts.

Assertion details
  • Input: The periodic reporter calls startBucket more than once after a serialization failure.
  • Expected: The test must require exactly one startBucket call, as the original Groovy test does.
  • Actual: The migrated test uses atLeastOnce(). It passes when startBucket runs two or more times.
Suggested change
verify(writer, atLeastOnce()).startBucket(anyInt(), anyLong(), anyLong());
verify(writer, times(1)).startBucket(anyInt(), anyLong(), anyLong());

Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

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

Labels

comp: testing Testing tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant