Skip to content

Port TraceMapperV0_4/V0_5 payload tests from Spock to JUnit 5 - #11871

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
dougqh/port-tracemapper-tests
Jul 29, 2026
Merged

Port TraceMapperV0_4/V0_5 payload tests from Spock to JUnit 5#11871
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
dougqh/port-tracemapper-tests

Conversation

@dougqh

@dougqh dougqh commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Migrates TraceMapperV04PayloadTest and TraceMapperV05PayloadTest from Groovy/Spock to JUnit 5 Java. TraceMapperV1PayloadTest and TraceMapperTest are left untouched (V1 is newer and not yet in production — deferred).

Motivation

Moving away from Groovy - wanted to clean-up before doing further optimizations in v04 & v05 serialization code

Additional Notes

From Claude...

  • Both where: tables → @MethodSource providers, preserving the 10<<10/100<<10 shift intent (not flattened to decimals).
  • V0.4's metaStruct verifier closure → a @FunctionalInterface MetaStructVerifier<E>.
  • The format-agnostic decode helpers — assertEqualsWithNullAsEmpty, the metrics unpackNumber switch, and the growable capturing WritableByteChannel — are extracted to a shared PayloadVerifiers helper reused by both tests. The two PayloadVerifiers themselves stay per-test because V0.4 (inline strings) and V0.5 (dictionary-compressed string indices) decode different wire formats.

Two behaviors that DDSpecification / Groovy provided implicitly are now explicit:

  1. Numeric metrics are compared via longValue(). Groovy's dynamic dispatch routed assertEquals(Long, Integer) to the primitive assertEquals(long, long) overload (numeric equality); Java's static overload resolution would pick the Object overload and compare by reference type, which fails once msgpack's minimal encoding narrows a Long thread id back to an Integer.
  2. ProcessTags lifecycle: the ProcessTags static is re-synced to the per-test Config via @ExtendWith(WithConfigExtension.class) + a @BeforeEach, and the body-overflow test disables process tags with @WithConfig (so the dictionary-size calculation stays stable).

Testing

Test count is unchanged: V0.4 = 23, V0.5 = 30 (53 total), all green. Verified the original Groovy suite passes in the same environment before porting.

🤖 Generated with Claude Code

Migrate TraceMapperV04PayloadTest and TraceMapperV05PayloadTest from
Groovy/Spock to JUnit 5 Java (V0.1/V1 deferred). The two `where:` tables
become @MethodSource providers (preserving the `10<<10` shift intent),
the V0.4 metaStruct closure becomes a @FunctionalInterface, and the
format-agnostic decode helpers (assertEqualsWithNullAsEmpty, the metrics
unpackNumber switch, and the growable capturing channel) are extracted to
a shared PayloadVerifiers helper reused by both. The two format-specific
PayloadVerifiers stay per-test since V0.4 (inline strings) and V0.5
(dictionary-compressed indices) decode different wire formats.

Two behaviors DDSpecification/Groovy provided implicitly are made
explicit: (1) numeric metrics are compared via longValue() — Groovy's
dynamic dispatch routed assertEquals(Long,Integer) to the primitive
long overload, whereas Java's static resolution would compare by
reference type after msgpack's minimal encoding narrows a Long to an
Integer; (2) the ProcessTags static is re-synced to the per-test Config
via @ExtendWith(WithConfigExtension) + a @beforeeach, with the overflow
test disabling process tags via @WithConfig.

Test count is unchanged (V0.4=23, V0.5=30).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dougqh dougqh added comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: refactoring labels Jul 6, 2026
@datadog-prod-us1-5

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jul 6, 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 13.99 s 13.97 s [-0.7%; +1.0%] (no difference)
startup:insecure-bank:tracing:Agent 12.91 s 13.00 s [-1.4%; -0.1%] (maybe better)
startup:petclinic:appsec:Agent 16.93 s 16.73 s [+0.2%; +2.2%] (maybe worse)
startup:petclinic:iast:Agent 16.33 s 16.95 s [-8.0%; +0.7%] (no difference)
startup:petclinic:profiling:Agent 16.86 s 16.86 s [-1.2%; +1.2%] (no difference)
startup:petclinic:sca:Agent 16.92 s 16.84 s [-0.6%; +1.5%] (no difference)
startup:petclinic:tracing:Agent 16.06 s 16.01 s [-0.6%; +1.2%] (no difference)

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

@dougqh
dougqh marked this pull request as ready for review July 22, 2026 16:12
@dougqh
dougqh requested a review from a team as a code owner July 22, 2026 16:12
@dougqh
dougqh requested a review from mhlidd July 22, 2026 16:12
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

View session in Datadog

Bits Code status: ✅ Done

Comment @DataDog to request changes

@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: 9a68d1ce53

ℹ️ 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".

Comment on lines +28 to +29
import datadog.trace.junit.utils.config.WithConfig;
import datadog.trace.junit.utils.config.WithConfigExtension;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Import the existing WithConfig test utilities

A repo-wide search shows WithConfig and WithConfigExtension are provided under datadog.trace.test.junit.utils.config, not datadog.trace.junit.utils.config. As written, these imports leave both migrated test classes with unresolved symbols and break dd-trace-core test compilation until the imports are changed to the actual package.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — fixed in 2c7643e. The utilities live under datadog.trace.test.junit.utils.config and my migration used the old package. 👍

// disable process tags since they are only on the first span of the chunk otherwise the
// calculation woes
@Test
@WithConfig(key = EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, value = "false")

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 Reset process tags after disabling them

This test now disables process-tag propagation through @WithConfig, and the class @BeforeEach syncs the ProcessTags static to that disabled Config; however, WithConfigExtension only rebuilds Config after the method and does not reset ProcessTags. If this method is the last one run in the class, later tests in the same Gradle test JVM can observe process tags still disabled, whereas the original Spock cleanup explicitly re-enabled the config and reset ProcessTags.

Useful? React with 👍 / 👎.

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 seems accurate, albeit unlikely. Still worth a fix IMO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Added an @AfterAll ProcessTags.reset(Config.get()) in 2c7643e, matching DDSpanSerializationTest — by afterAll the extension has already restored Config to its defaults, so this resets the static and prevents the disabled state leaking across the shared test JVM. 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2c7643e — added an @AfterAll ProcessTags.reset(Config.get()), mirroring DDSpanSerializationTest. By afterAll the extension has restored Config to defaults, so the static gets reset and can't leak into other tests in the shared JVM.

import datadog.trace.common.writer.Payload;
import datadog.trace.common.writer.TraceGenerator.PojoSpan;
import datadog.trace.core.DDSpanContext;
import datadog.trace.junit.utils.config.WithConfigExtension;

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.

Suggested change
import datadog.trace.junit.utils.config.WithConfigExtension;
import datadog.trace.test.junit.utils.config.WithConfigExtension;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2c7643e.

import datadog.trace.common.writer.TraceGenerator.PojoSpan;
import datadog.trace.core.DDSpanContext;
import datadog.trace.junit.utils.config.WithConfig;
import datadog.trace.junit.utils.config.WithConfigExtension;

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.

Suggested change
import datadog.trace.junit.utils.config.WithConfigExtension;
import datadog.trace.test.junit.utils.config.WithConfigExtension;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2c7643e.

// disable process tags since they are only on the first span of the chunk otherwise the
// calculation woes
@Test
@WithConfig(key = EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, value = "false")

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 seems accurate, albeit unlikely. Still worth a fix IMO.

The migrated tests imported datadog.trace.junit.utils.config.* but the
utilities live in datadog.trace.test.junit.utils.config.* — the wrong
package broke dd-trace-core test compilation. Correct the imports in
both V0.4 and V0.5 payload tests.

V0.5 disables process-tag propagation via a method-level @WithConfig.
WithConfigExtension rebuilds Config after each test but does not reset
the ProcessTags static, so a disabled state could leak into other tests
in the same Gradle JVM (the original Spock cleanup reset it explicitly).
Add an @afterall ProcessTags.reset, mirroring DDSpanSerializationTest.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@mhlidd mhlidd 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.

LGTM

@dougqh
dougqh added this pull request to the merge queue Jul 29, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 29, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-29 11:36:09 UTC ℹ️ Start processing command /merge


2026-07-29 11:36:14 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-29 12:25:04 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 Jul 29, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 1d6abf8 into master Jul 29, 2026
587 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dougqh/port-tracemapper-tests branch July 29, 2026 12:25
@github-actions github-actions Bot added this to the 1.65.0 milestone Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM 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.

2 participants