Skip to content

Migrate dd-trace-core groovy files to java part 9#11488

Open
jpbempel wants to merge 2 commits into
masterfrom
jpbempel/g2j-core-pt9
Open

Migrate dd-trace-core groovy files to java part 9#11488
jpbempel wants to merge 2 commits into
masterfrom
jpbempel/g2j-core-pt9

Conversation

@jpbempel
Copy link
Copy Markdown
Member

What Does This Do

we migrate 20 tests from the propagation package:

  • TagKeyTest
  • TagValueTest
  • B3HttpExtractorTest
  • B3HttpInjectorPaddedTest
  • B3HttpInjectorTest
  • DatadogHttpExtractorTest
  • DatadogHttpInjectorTest
  • DatadogPropagationTagsTest
  • HaystackHttpExtractorTest
  • HaystackHttpInjectorTest
  • HttpExtractorTest
  • HttpInjectorB3PaddingTest
  • HttpInjectorTest
  • NoneHttpExtractorTest
  • TracingPropagatorTest
  • W3CHttpExtractorTest
  • W3CHttpInjectorTest
  • W3CPropagationTagsTest
  • XRayHttpExtractorTest
  • XRayHttpInjectorTest

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

Additional Notes

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
    • Get more information in this doc

Jira ticket: [PROJ-IDENT]

@jpbempel jpbempel requested review from a team as code owners May 28, 2026 12:21
@jpbempel jpbempel requested review from mcculls and mtoffl01 and removed request for a team May 28, 2026 12:21
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 28, 2026

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.

@datadog-official
Copy link
Copy Markdown
Contributor

datadog-official Bot commented May 28, 2026

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 3 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-java | spotless   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). Spotless Java check failed due to format violations in TracingPropagatorTest.java. Run './gradlew spotlessApply' to fix issues.

Run system tests | main / Build end-to-end (spring-boot-3-native)   View in Datadog   GitHub Actions

🔄 Retry job. This looks flaky and may succeed on retry. Artifact generation failed: corrupted deflate data while loading image from binaries/java-spring-boot-3-native-weblog.tar.gz

Run system tests | Check system tests success   View in Datadog   GitHub Actions

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 588ea9b | Docs | Datadog PR Page | Give us feedback!

@jpbempel jpbempel added comp: testing Testing tag: no release notes Changes to exclude from release notes labels May 28, 2026
Copy link
Copy Markdown
Contributor

@bric3 bric3 left a comment

Choose a reason for hiding this comment

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

Conversion-specific Mockito comments.

singletonMap("k", "v"));
Map<String, String> carrier = mock(Map.class);

mockedContext.beginEndToEnd();
Copy link
Copy Markdown
Contributor

@bric3 bric3 May 28, 2026

Choose a reason for hiding this comment

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

The Groovy test verified both time-source calls before 0 * _, but this conversion only checks the carrier. Suggested fix: clear the stubbing/build noise before beginEndToEnd(), then verify the two time-source calls too.

clearInvocations(timeSource);

mockedContext.beginEndToEnd();
injector.inject(mockedContext, carrier, MapSetter.INSTANCE);

verify(timeSource).getCurrentTimeNanos();
verify(timeSource).getNanoTicks();
verify(carrier)
    .put(
        "X-Amzn-Trace-Id",
        "Root=1-633c7675-000000000000000000000001;Parent=0000000000000002;_dd.origin=fakeOrigin;t0=1664906869195;k=v");
verifyNoMoreInteractions(timeSource, carrier);

That keeps the Mockito version as strict as the original Spock interaction block.

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.

done


propagator.inject(span, carrier, setter);

verify(injector).inject(any(DDSpanContext.class), same(carrier), any());
Copy link
Copy Markdown
Contributor

@bric3 bric3 May 28, 2026

Choose a reason for hiding this comment

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

The Spock assertion matched span.context() specifically. Suggested fix: keep that exact-context check in the Mockito verify instead of accepting any DDSpanContext.

verify(injector).inject(same((DDSpanContext) span.context()), same(carrier), any());

same is already statically imported here, so this keeps the conversion tight without adding much noise.

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.

done


propagator.inject(span, carrier, setter);

verify(injector, times(injected)).inject(any(DDSpanContext.class), same(carrier), any());
Copy link
Copy Markdown
Contributor

@bric3 bric3 May 28, 2026

Choose a reason for hiding this comment

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

Same conversion concern here: the original interaction was tied to span.context(). Suggested fix: keep the times(injected) behavior, but match the same context instance.

verify(injector, times(injected))
    .inject(same((DDSpanContext) span.context()), same(carrier), any());

That preserves the old assertion while keeping the converted table-test flow.

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.

done

jpbempel added 2 commits May 28, 2026 19:09
we migrate 20 tests from the propagation package:
 - TagKeyTest
 - TagValueTest
 - B3HttpExtractorTest
 - B3HttpInjectorPaddedTest
 - B3HttpInjectorTest
 - DatadogHttpExtractorTest
 - DatadogHttpInjectorTest
 - DatadogPropagationTagsTest
 - HaystackHttpExtractorTest
 - HaystackHttpInjectorTest
 - HttpExtractorTest
 - HttpInjectorB3PaddingTest
 - HttpInjectorTest
 - NoneHttpExtractorTest
 - TracingPropagatorTest
 - W3CHttpExtractorTest
 - W3CHttpInjectorTest
 - W3CPropagationTagsTest
 - XRayHttpExtractorTest
 - XRayHttpInjectorTest
@jpbempel jpbempel force-pushed the jpbempel/g2j-core-pt9 branch from 952a80e to 588ea9b Compare May 28, 2026 17:09
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 28, 2026

🟢 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

Startup Time

Scenario This PR master Change
insecure-bank / iast 14,058 ms 13,852 ms +1.5%
insecure-bank / tracing 12,970 ms 12,962 ms +0.1%
petclinic / appsec 16,500 ms 16,453 ms +0.3%
petclinic / iast 16,429 ms 16,635 ms -1.2%
petclinic / profiling 16,658 ms 16,495 ms +1.0%
petclinic / tracing 16,035 ms 15,980 ms +0.3%

Commit: 588ea9b9 · 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants