Skip to content

Migrate dd-trace-core groovy files to java part 12 - #11619

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 10 commits into
masterfrom
jpbempel/g2j-core-pt12
Aug 20, 2026
Merged

Migrate dd-trace-core groovy files to java part 12#11619
gh-worker-dd-mergequeue-cf854d[bot] merged 10 commits into
masterfrom
jpbempel/g2j-core-pt12

Conversation

@jpbempel

@jpbempel jpbempel commented Jun 10, 2026

Copy link
Copy Markdown
Member

What Does This Do

we migrate 17 tests:

  • DDEvpProxyApiTest
  • DDIntakeApiTest
  • DDIntakeTraceInterceptorTest
  • DDIntakeTrackTypeResolverTest
  • DDAgentApiTest
  • DDAgentWriterCombinedTest
  • DDAgentWriterTest
  • DDIntakeWriterCombinedTest
  • DDIntakeWriterTest
  • MultiWriterTest
  • PayloadDispatcherImplTest
  • PrioritizationTest
  • SerializationTest
  • SpanSamplingWorkerTest
  • TraceMapperTest
  • TraceProcessingWorkerTest
  • WriterFactoryTest

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

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 (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: [PROJ-IDENT]

@jpbempel
jpbempel requested a review from a team as a code owner June 10, 2026 15:15
@jpbempel
jpbempel requested a review from PerfectSlayer June 10, 2026 15:15
@dd-octo-sts

dd-octo-sts Bot commented Jun 10, 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.

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 58.41% (-0.19%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: caa69aa | Docs | View more details | Give us feedback!

@jpbempel jpbempel added comp: testing Testing tag: no release notes Changes to exclude from release notes type: refactoring labels Jun 10, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jun 10, 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 14.05 s [-1.1%; +0.5%] (no difference)
startup:insecure-bank:tracing:Agent 12.92 s 13.03 s [-1.5%; -0.2%] (maybe better)
startup:petclinic:appsec:Agent 17.50 s 16.91 s [-1.0%; +7.9%] (no difference)
startup:petclinic:iast:Agent 16.80 s 17.48 s [-8.2%; +0.4%] (no difference)
startup:petclinic:profiling:Agent 17.43 s 17.46 s [-1.2%; +0.8%] (no difference)
startup:petclinic:sca:Agent 17.40 s 17.36 s [-0.8%; +1.3%] (no difference)
startup:petclinic:tracing:Agent 16.60 s 16.69 s [-1.5%; +0.5%] (no difference)

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

Comment on lines +444 to +450
private static void assertEqualsWithNullAsEmpty(CharSequence expected, CharSequence actual) {
if (null == expected) {
assertEquals("", actual);
} else {
assertEquals(expected.toString(), actual.toString());
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to use ? operator instead?
And also, I'm a bit skeptical about Yoda style in general, maybe make sense to update skill to not use it for migrated code?

Suggested change
private static void assertEqualsWithNullAsEmpty(CharSequence expected, CharSequence actual) {
if (null == expected) {
assertEquals("", actual);
} else {
assertEquals(expected.toString(), actual.toString());
}
}
private static void assertEqualsWithNullAsEmpty(CharSequence expected, CharSequence actual) {
assertEquals(expected == null ? "" : expected.toString(), actual.toString());
}

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
agree on yoda conditions, totally useless in Java. some people use this style inherited from C/C++ 🤷

Comment on lines +55 to +57
// disable process tags since they are only on the first span of the chunk otherwise the
// calculation woes
// 4x 36 ASCII characters and 2 bytes of msgpack string prefix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: can be 2 lines of comments

// calculation woes
// 4x 36 ASCII characters and 2 bytes of msgpack string prefix
int dictionarySpacePerTrace = 4 * (36 + 2);
// enough space for two traces with distinct string values, plus the header

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just an idea, maybe worth to add into skill to write comments as normal sentences?
With Capital letter first word, and . at the end...

Suggested change
// enough space for two traces with distinct string values, plus the header
// Enough space for two traces with distinct string values, plus the header.

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.

we really care about this, you can add it to the skill. personally I don't mind.

Comment on lines +238 to +264
for (int k = 0; k < spanCount; ++k) {
TraceGenerator.PojoSpan expectedSpan = expectedTrace.get(k);
int elementCount = unpacker.unpackArrayHeader();
assertEquals(12, elementCount);
String serviceName = dictionary[unpacker.unpackInt()];
assertEqualsWithNullAsEmpty(expectedSpan.getServiceName(), serviceName);
String operationName = dictionary[unpacker.unpackInt()];
assertEqualsWithNullAsEmpty(expectedSpan.getOperationName(), operationName);
String resourceName = dictionary[unpacker.unpackInt()];
assertEqualsWithNullAsEmpty(expectedSpan.getResourceName(), resourceName);
long traceId = unpacker.unpackValue().asNumberValue().toLong();
assertEquals(expectedSpan.getTraceId().toLong(), traceId);
long spanId = unpacker.unpackValue().asNumberValue().toLong();
assertEquals(expectedSpan.getSpanId(), spanId);
long parentId = unpacker.unpackValue().asNumberValue().toLong();
assertEquals(expectedSpan.getParentId(), parentId);
long startTime = unpacker.unpackLong();
assertEquals(expectedSpan.getStartTime(), startTime);
long duration = unpacker.unpackLong();
assertEquals(expectedSpan.getDurationNano(), duration);
int error = unpacker.unpackInt();
assertEquals(expectedSpan.getError(), error);
int metaSize = unpacker.unpackMapHeader();
HashMap<String, String> meta = new HashMap<>();
for (int j = 0; j < metaSize; ++j) {
meta.put(dictionary[unpacker.unpackInt()], dictionary[unpacker.unpackInt()]);
}

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD Jun 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Also an idea if we can instruct skill to apply better readability here?
Adding empty lines between asserts helps to read code better.
like:

            TraceGenerator.PojoSpan expectedSpan = expectedTrace.get(k);
            int elementCount = unpacker.unpackArrayHeader();
            assertEquals(12, elementCount);

            String serviceName = dictionary[unpacker.unpackInt()];
            assertEqualsWithNullAsEmpty(expectedSpan.getServiceName(), serviceName);

            String operationName = dictionary[unpacker.unpackInt()];
            assertEqualsWithNullAsEmpty(expectedSpan.getOperationName(), operationName);

            String resourceName = dictionary[unpacker.unpackInt()];
            assertEqualsWithNullAsEmpty(expectedSpan.getResourceName(), resourceName);
...

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.

I personally prefer avoid empty lines. I feel that adding this to the skill will result in weird behavior.

Comment on lines +266 to +276
if (Tags.HTTP_STATUS.equals(entry.getKey())) {
assertEquals(String.valueOf(expectedSpan.getHttpStatusCode()), entry.getValue());
} else if (DDTags.ORIGIN_KEY.equals(entry.getKey())) {
assertEquals(expectedSpan.getOrigin(), entry.getValue());
} else if (DDTags.PROCESS_TAGS.equals(entry.getKey())) {
processTagsCount++;
assertTrue(Config.get().isExperimentalPropagateProcessTagsEnabled());
assertEquals(0, k);
assertEquals(ProcessTags.getTagsForSerialization().toString(), entry.getValue());
} else {
Object tag = expectedSpan.getTag(entry.getKey());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like switch can be used here?

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

Comment on lines +21 to +22
boolean ciVisibilityEnabled,
boolean ciVisibilityAgentlessEnabled,

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD Jun 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: ciVis prefix would be shorter and more readable, IMHO.

Comment on lines +35 to +46

HealthMetrics monitor = mock(HealthMetrics.class);
TraceProcessingWorker worker = mock(TraceProcessingWorker.class);
DDAgentFeaturesDiscovery discovery = mock(DDAgentFeaturesDiscovery.class);
DDAgentApi api = mock(DDAgentApi.class);
MonitoringImpl monitoring = new MonitoringImpl(StatsDClient.NO_OP, 1, TimeUnit.SECONDS);
PayloadDispatcherImpl dispatcher =
new PayloadDispatcherImpl(new DDAgentMapperDiscovery(discovery), api, monitor, monitoring);
DDAgentWriter writer = new DDAgentWriter(worker, dispatcher, monitor, 1, TimeUnit.SECONDS, false);

// Only used to create spans
CoreTracer dummyTracer;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Not sure why but looks like skill tends to not use private + final (where applicable). I saw such code several times in previous PRs. Probably worth to add to skill?

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.

honestly don't care for test + it's shorter

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD Jun 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep, but it is some sort of habit for me, like I feel pain when I see code written in Python-all-global style :)
Just kidding...

@AfterEach
void cleanup() {
writer.close();
if (dummyTracer != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Why we need check for != null if we create it in setup()?

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

TraceProcessingWorker worker = mock(TraceProcessingWorker.class);
DDAgentFeaturesDiscovery discovery = mock(DDAgentFeaturesDiscovery.class);
DDAgentApi api = mock(DDAgentApi.class);
MonitoringImpl monitoring = new MonitoringImpl(StatsDClient.NO_OP, 1, TimeUnit.SECONDS);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I would use static import for TimeUnit.SECONDS.

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

new DDAgentWriter(localWorker, localDispatcher, localMonitor, 1, TimeUnit.SECONDS, false);

DDSpan p0 = newSpan();
List<DDSpan> trace = java.util.Arrays.asList(p0, newSpan());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: FQN required here?

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

Comment on lines +212 to +213
DDSpan p0 = newSpan();
List<DDSpan> trace = java.util.Arrays.asList(p0, newSpan());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This code looks a bit confusing. Why one span created as variable and second as inlined call? Here and similar places.
How about just: List<DDSpan> trace = asList(newSpan(), newSpan()); ?
Found in Google:
Java will never reorder the execution of method calls passed as arguments to another method. The Java Language Specification (JLS) Section 15.7 strictly guarantees that all expressions and arguments are evaluated from left to right.

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


DDSpan newSpan() {
// Use the UNSET-priority variant so setSamplingPriority() can change the priority later
return buildSpan(0L, "test.tag", "test.value", PropagationTags.factory().empty());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: why not use PrioritySampling.UNSET instead of 0L?

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.

because here 0L is the timestamp not the priority

@jpbempel
jpbempel force-pushed the jpbempel/g2j-core-pt12 branch from 9cf428e to c71437c Compare June 10, 2026 17:06

@PerfectSlayer PerfectSlayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I will do a review by the end of the week. Can you hold it until then if already approved?
I would like to extract feedback from my manual changes and see if anything can relate to those changes (additionally to review them manually).

@bric3 bric3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I spot a few issues in the port, it's mostly weaker tests. But there are some improvements to the tests themselves that I think should fit in this port.

Comment thread dd-trace-core/src/test/java/datadog/trace/common/writer/DDAgentWriterTest.java Outdated
Comment thread dd-trace-core/src/test/java/datadog/trace/common/writer/DDAgentWriterTest.java Outdated
Comment thread dd-trace-core/src/test/java/datadog/trace/common/writer/DDAgentApiTest.java Outdated
Comment on lines +400 to +402
} finally {
agent.close();
}

@bric3 bric3 Jun 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: I think this can be quickly improved everywhere as a try-with-resources as agent is an AutoCloseable type.

@bric3 bric3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can move forward.

I think I'd prefer to use the try-with-resources where applicable as part of the port though.

@PerfectSlayer

Copy link
Copy Markdown
Collaborator

Starting the review 👀

@PerfectSlayer

Copy link
Copy Markdown
Collaborator

❔ question: ‏ Can I push changes from the automatic review I created in #11636 or would you prefer to paste all findings as comments?

@PerfectSlayer PerfectSlayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Flushing comments for dd-trace-core/src/test/java/datadog/trace/common/writer/ddagent/TraceMapperV04PayloadTest.java.

It's going to be a long review. I wonder if we should not split it and pair with the original author so they could fix the issues before considering merging this test implementation.

class TraceMapperV04PayloadTest extends DDJavaSpecification {

@TableTest({
"scenario | bufferSize | traceCount | lowCardinality",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔨 issue: ‏buffer size were migrated to magic numbers. Better use MethodSource and build arguments so we can keep the meaning.

Comment on lines +91 to +93
arguments(DD64bTraceId.ONE, 2L, 3L),
arguments(DD64bTraceId.MAX, 2L, 3L),
arguments(DD64bTraceId.from(-10), -11L, -12L));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔨 issue: ‏This is a trace id converter for 1 and MAX at least

Comment on lines +110 to +118
Collections.emptyMap(),
Collections.emptyMap(),
"type",
false,
0,
0,
"origin");
List<List<TraceGenerator.PojoSpan>> traces =
Collections.singletonList(Collections.singletonList(span));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🎯 suggestion: ‏Would be easier to read if we use static import for emptyMap() and singletonList()

traceMapper,
(expectedObj, received) -> {
List<?> expected = (List<?>) expectedObj;
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(received);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

💭 thought: ‏The packer is never close. Maybe use try-with-resources?

traces,
traceMapper,
(expectedObj, received) -> {
List<?> expected = (List<?>) expectedObj;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🎯 suggestion: ‏Check type first?

"origin"));
}

List<List<TraceGenerator.PojoSpan>> traces = Collections.singletonList(spans);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

💭 thought: ‏That will be nice the day we get var or an equivalent syntactic sugar :)

@bric3 bric3 Jul 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Kotlin's Typealias ☺️

// --- Inner classes ---

private interface MetaStructVerifier {
void verify(Object expected, byte[] received) throws IOException;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

❔ question: ‏It loosed the generic type. Should we keep it or improve it? Because there is only 1 usage in this test file.

Payload payload = mapper.newPayload().withBody(messageCount, buffer);
payload.writeTo(this);
captured.flip();
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(captured);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔨 issue: ‏Same here, unpacker not closed.

Comment on lines +340 to +341
if (DD_MEASURED.toString().equals(key)) {
assertTrue(metricValue.intValue() == 1 || !expectedSpan.isMeasured());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🎯 suggestion: ‏The assertion around span measured is confusing and can be simplified.

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.

how?

Comment on lines +353 to +354
for (Map.Entry<String, Number> metric : metrics.entrySet()) {
if (metric.getValue() instanceof Double || metric.getValue() instanceof Float) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🎯 suggestion: ‏Poor readability. metrics.forEach() would improve it a bit at least.

@jpbempel
jpbempel force-pushed the jpbempel/g2j-core-pt12 branch from 2cc67b3 to 35a718a Compare June 17, 2026 11:15
@jpbempel
jpbempel force-pushed the jpbempel/g2j-core-pt12 branch 2 times, most recently from 4ea79e9 to 8796f31 Compare July 7, 2026 09:11
@jpbempel
jpbempel force-pushed the jpbempel/g2j-core-pt12 branch from 4d30733 to e120ab9 Compare August 19, 2026 16:18
@jpbempel
jpbempel requested a review from a team as a code owner August 20, 2026 07:39
@jpbempel
jpbempel requested review from ygree and removed request for a team August 20, 2026 07:39

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Datadog Autotest: FAIL

Several migrated tests accept wrong metric arguments or omit required negative checks. The dropped-trace test also uses an unset priority, so it no longer checks the dropped-priority path.

Open Bits AI session

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

DDSpan p0 = newSpan();
List<DDSpan> trace = java.util.Arrays.asList(p0, newSpan());

when(worker.publish(eq(trace.get(0)), anyInt(), eq(trace))).thenReturn(publishResult);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Restore the dropped sampling priority

A wrong sampling priority in the intake writer can pass this test.

Assertion details
  • Input: Run testDroppedTraceIsCounted with either dropped publish result.
  • Expected: The migrated test must send SAMPLER_DROP to worker.publish, as the former test does.
  • Actual: The span keeps the UNSET priority. The anyInt() matcher accepts this value. Set p0 to SAMPLER_DROP and require that value in both publish checks.

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

return null;
})
.when(healthMetrics)
.onFailedSerialize(any(), any());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Check the exact serialization error

The worker can replace the serialization error without a test failure.

Assertion details
  • Input: PayloadDispatcherImpl.addTrace throws theError during trace processing.
  • Expected: The health metric callback must receive the exact exception from addTrace.
  • Actual: The any() matcher accepts a different throwable. Use the same theError object in the callback matcher and keep the asynchronous counter.

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

if (expectedSubmitted == acceptedCount.get()) break;
Thread.sleep(50);
}
assertEquals(expectedSubmitted, acceptedCount.get());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Reject unexpected serialization failures

An extra serialization failure report can pass this test.

Assertion details
  • Input: Process any table row in testTracesShouldBeProcessed.
  • Expected: Accepted traces dispatch without a serialization failure metric.
  • Actual: The test checks only the dispatch count. Add a negative check for healthMetrics.onFailedSerialize after processing completes.

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


// monitor is notified of successful publication
verify(worker).publish(any(), anyInt(), eq(trace));
verify(monitor).onPublish(any(), anyInt());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Check the published trace

A writer can report metrics for the wrong trace without a test failure.

Assertion details
  • Input: A writer publishes one trace successfully.
  • Expected: onPublish must receive the same trace that writer.write receives.
  • Actual: The any() matcher accepts a different trace. Restore the exact trace matcher in this test and in the equivalent intake and combined writer tests.

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

verify(healthMetrics, times(1)).onFlush(false);
verify(healthMetrics, times(1))
.onSend(
anyInt(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Check the sent trace count

Wrong trace-count metrics can pass the migrated tests.

Assertion details
  • Input: The monitor test writes and sends one trace.
  • Expected: onSend and onFailedSend must report one trace for these requests.
  • Actual: The first anyInt() matcher accepts a wrong trace count. Require 1 in the agent and intake happy-path and error monitor tests.

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

increase timeout
@jpbempel
jpbempel force-pushed the jpbempel/g2j-core-pt12 branch from 9d23634 to b83b8cc Compare August 20, 2026 08:32

@bric3 bric3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pre approve

Comment on lines +140 to +169
JavaTestHttpServer intake =
JavaTestHttpServer.httpServer(
s ->
s.handlers(
h ->
h.post(
path,
api -> {
if (retry[0] < 1) {
api.getResponse()
.status(429)
.addHeader("x-ratelimit-reset", "0")
.send();
retry[0]++;
} else {
api.getResponse().status(200).send();
}
})));
DDIntakeApi client = createIntakeApi(intake.getAddress().toString(), trackType);
Payload payload = prepareTraces(trackType, Collections.emptyList());

try {
RemoteApi.Response clientResponse = client.sendSerializedTraces(payload);
assertTrue(clientResponse.success());
assertTrue(clientResponse.status().isPresent());
assertEquals(200, clientResponse.status().getAsInt());
assertEquals(path, intake.getLastRequest().getPath());
} finally {
intake.close();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: FYI, I'd use the try with resources: #11619 (comment)

But I understand why it's not, so it's a nitpick, rather than something to fix

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

Comment on lines +74 to +85
try {
// heartbeat occurs automatically
long deadline = System.currentTimeMillis() + 5000;
while (System.currentTimeMillis() < deadline) {
if (flushCount.get() > 0) break;
Thread.sleep(50);
}
assertTrue(flushCount.get() > 0);
} finally {
// cleanup
worker.close();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

note: Note this one is not using try with resources

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

ByteBuffer dictionaryBytes = dictionaryBuffer.slice();
Map<String, String> meta = new HashMap<>();

MessageUnpacker dictionaryUnpacker = MessagePack.newDefaultUnpacker(dictionaryBytes);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

note: MessageUnpacker is closeable as well, maybe it needs to be within a try with resources

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

@jpbempel
jpbempel added this pull request to the merge queue Aug 20, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 20, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-20 16:31:55 UTC ℹ️ Start processing command /merge


2026-08-20 16:32:00 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 2h (p90).


2026-08-20 17:04:35 UTCMergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for 347f5a4:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 20, 2026
@jpbempel
jpbempel added this pull request to the merge queue Aug 20, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 20, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-20 19:19:36 UTC ℹ️ Start processing command /merge


2026-08-20 19:19:41 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 2h (p90).


2026-08-20 20:00:05 UTCMergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for fe0bc43:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 20, 2026
@jpbempel
jpbempel added this pull request to the merge queue Aug 20, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 20, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-20 20:38:03 UTC ℹ️ Start processing command /merge


2026-08-20 20:38:08 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 2h (p90).


2026-08-20 21:31:27 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 20, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 2d8d93d into master Aug 20, 2026
591 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the jpbempel/g2j-core-pt12 branch August 20, 2026 21:31
@github-actions github-actions Bot added this to the 1.66.0 milestone Aug 20, 2026
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.

4 participants