Skip to content

Clean up AI generated code#11581

Open
PerfectSlayer wants to merge 15 commits into
masterfrom
bbujon/groovy-to-java
Open

Clean up AI generated code#11581
PerfectSlayer wants to merge 15 commits into
masterfrom
bbujon/groovy-to-java

Conversation

@PerfectSlayer
Copy link
Copy Markdown
Contributor

What Does This Do

Clean up AI generated code...
I keep focusing on cleaning up the propagation related tests. There is still a lot of duplication between the propagators but at least that should improve readability.

Motivation

Many details were lost. Intention were lost. Code got bloated on some parts.

Additional Notes

If it helps, here an short AI-generated summary of the changes:

  • Injector tests: replaced Mockito mock carriers with real HashMap, using assertEquals on carrier contents and size instead of verify/verifyNoMoreInteractions.
  • Extractor tests: introduced a shared headers(key, value, ...) factory (in HttpCodecTestHelper) that uppercases keys, skips null values, and eliminates the repeated new HashMap<>() + sequential .put() boilerplate across all 6 extractor tests. Optional headers previously guarded by if blocks become null ternaries.
  • Table test constants: TraceIdConverter resolves symbolic names (TRACE_ID_MAX, TRACE_ID_MAX-1, TRACE_ID_MAX+1) replacing raw uint64 literals. W3cConstantConverter
    does the same for W3C header constants. Both use @ConvertWith since tabletest bypasses @TypeConverter for String parameters.
  • Misc:
    • extracted mockSpanContext() helpers,
    • moved tracer lifecycle to @BeforeEach/@AfterEach,
    • dedicated comma test in NoneHttpExtractorTest,
    • fixed a pre-existing bug where extractHttpHeadersWithOutOfRangeTraceId was asserting on a valid ID instead of an out-of-range one.

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]

@PerfectSlayer PerfectSlayer requested a review from a team as a code owner June 5, 2026 16:30
@PerfectSlayer PerfectSlayer requested a review from dougqh June 5, 2026 16:30
@PerfectSlayer PerfectSlayer added comp: core Tracer core tag: no release notes Changes to exclude from release notes type: refactoring labels Jun 5, 2026
@PerfectSlayer PerfectSlayer changed the title Bbujon/groovy to java Clean up AI generated code Jun 5, 2026
Copy link
Copy Markdown

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

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: ea81579503

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

"DATADOG,B3MULTI b3 trace out of range | [DATADOG, B3MULTI] | '1' | '2' | '18446744073709551616' | 'b' | | '1' | '2' | true | false | false | false ",
"DATADOG,B3MULTI b3 span out of range | [DATADOG, B3MULTI] | '1' | '2' | 'a' | '18446744073709551616' | | '1' | '2' | true | false | false | false ",
"NONE | [NONE] | '1' | '2' | | | | | | true | false | true | false ",
"DATADOG,TRACECONTEXT w3c override | [DATADOG, TRACECONTEXT] | '1' | '2' | | | 'W3C_TRACE_PARENT' | '1' | 'W3C_SPAN_ID_LSTR' | false | false | false | 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 Convert W3C table constants before using them

These rows now pass symbolic values like 'W3C_TRACE_PARENT' and 'W3C_SPAN_ID_LSTR', but extractHttpHeadersUsingStyles still accepts plain String parameters without @ConvertWith(W3cConstantConverter.class). In the W3C override/extract-first scenarios, the extractor receives the literal invalid traceparent header W3C_TRACE_PARENT and the assertion later tries to parse W3C_SPAN_ID_LSTR as a span id, so these cases no longer exercise the W3C path and should fail at runtime.

Useful? React with 👍 / 👎.

@datadog-official
Copy link
Copy Markdown
Contributor

datadog-official Bot commented Jun 5, 2026

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 9 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-java | test_base: [11, 3/4]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-java | test_base: [17, 3/4]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-java | test_base: [21, 3/4]   View in Datadog   GitLab

View all 9 failed jobs.

Useful? React with 👍 / 👎

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

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Jun 5, 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
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.95 s 13.96 s [-1.0%; +0.9%] (no difference)
startup:insecure-bank:tracing:Agent 12.87 s 13.14 s [-3.0%; -1.1%] (significantly better)
startup:petclinic:appsec:Agent 16.35 s 16.28 s [-0.6%; +1.5%] (no difference)
startup:petclinic:iast:Agent 16.50 s 15.64 s [-3.6%; +14.6%] (unstable)
startup:petclinic:profiling:Agent 16.40 s 16.46 s [-1.3%; +0.6%] (no difference)
startup:petclinic:tracing:Agent 15.77 s 15.66 s [-0.9%; +2.2%] (no difference)

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

Copy link
Copy Markdown
Contributor

@dougqh dougqh left a comment

Choose a reason for hiding this comment

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

Code review comments from Claude (claude-sonnet-4-6) — correctness concerns identified during review.

headers.put(SOME_HEADER, "my-interesting-info");
// spotless:off
Map<String, String> headers = headers(
TRACE_ID_KEY, TRACE_ID_MAX_MINUS_1,
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.

[Claude] This uses TRACE_ID_MAX_MINUS_1 (= 2^64 - 2, a valid uint64), but the test is named extractHttpHeadersWithOutOfRangeTraceId. The original code used TRACE_ID_MAX.add(ONE) (= 2^64, truly out-of-range). The PR description says this is a fix, but the change appears backwards — TRACE_ID_MAX_PLUS_1 should be used here to preserve the original intent. The test likely still passes only because Haystack expects UUID-format IDs, so any bare decimal string is rejected regardless of its numeric value.

new LinkedHashSet<>(asList(DATADOG, TRACECONTEXT, BAGGAGE));
static final Set<PropagationStyle> DEFAULT_PROPAGATION_STYLE =
new LinkedHashSet<>(asList(PropagationStyle.DATADOG));
public static final boolean DEFAULT_PROPAGATION_B3_PADDING_ENABLED = true;
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.

[Claude] All other constants in this class are package-private (static final). Making this one public is inconsistent. If tests in other packages need it, consider exposing it via Config instead, or document why this one constant needs broader visibility.

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

Labels

comp: core Tracer core 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