Skip to content

[DO NOT MERGE] feat(sparkjava): Add sparkjava-gen-2.3 module (toolkit-generated)#11337

Draft
jordan-wong wants to merge 2 commits into
masterfrom
eval/sparkjava-2.3-gen-toolkit-attempt
Draft

[DO NOT MERGE] feat(sparkjava): Add sparkjava-gen-2.3 module (toolkit-generated)#11337
jordan-wong wants to merge 2 commits into
masterfrom
eval/sparkjava-2.3-gen-toolkit-attempt

Conversation

@jordan-wong
Copy link
Copy Markdown
Contributor

Summary

Adds a new module dd-java-agent/instrumentation/spark/sparkjava-2.3-gen containing an alternative SparkJava 2.3 instrumentation generated end-to-end by the APM instrumentation toolkit's new_integration workflow.

The new module is placed alongside the existing sparkjava-2.3 module (not replacing it) so reviewers can compare the toolkit-generated implementation against the canonical one side by side. This is a research artifact — the goal is to evaluate how well the toolkit can produce a Java instrumentation that passes CI without human intervention.

What's in this PR

Path Change
dd-java-agent/instrumentation/spark/sparkjava-2.3-gen/build.gradle New
dd-java-agent/instrumentation/spark/sparkjava-2.3-gen/src/main/java/.../SparkJavaInstrumentation.java New
dd-java-agent/instrumentation/spark/sparkjava-2.3-gen/src/test/groovy/.../SparkJavaServer.groovy New
dd-java-agent/instrumentation/spark/sparkjava-2.3-gen/src/test/groovy/.../SparkJavaTest.groovy New
settings.gradle.kts Register the new module

No changes to any production files or other modules.

How the toolkit produced this

One agent-driven workflow run from a blind baseline (the existing sparkjava-2.3 module was hidden from the agent). The workflow ran for ~2.5 hours, cost ~$74, and went through 10 reviewer iterations before the workflow exited.

Key choices the agent made:

  • Target: spark.route.Routes.find() — same instrumented type as the existing sparkjava-2.3 module (which is named RoutesInstrumentation)
  • Approach: enriches the existing Jetty server span with http.route rather than creating a new span. Matches existing pattern — Jetty is always the embedded server under SparkJava, so a server span always exists
  • Muzzle directives: open-ended [2.3,) with assertInverse = true
  • Tests: Spock specs extending HttpServerTest for full server-span validation

Verification

Local CI-equivalent verification on the new module:

./gradlew :dd-java-agent:instrumentation:spark:sparkjava-2.3-gen:check \
          :dd-java-agent:instrumentation:spark:sparkjava-2.3-gen:muzzle \
          :dd-java-agent:instrumentation:spark:sparkjava-2.3-gen:latestDepTest
BUILD SUCCESSFUL in 46s

Multi-JVM matrix (JVM 8/17/21/25) not run locally; the standard CI pipeline will exercise that.

Reviewer notes

The toolkit's internal reviewer step did NOT approve this module — it ran 10 iterations and exited with todos_remaining=7. The recurring spec-compliance complaint was that the agent should have instrumented spark.http.matching.MatcherFilter.doFilter (and created its own server span) instead of using Routes.find() + Jetty span enrichment.

I cross-referenced this against the existing sparkjava-2.3 module on master:

  • File: dd-java-agent/instrumentation/spark/sparkjava-2.3/src/main/java/datadog/trace/instrumentation/sparkjava/RoutesInstrumentation.java
  • instrumentedType() returns "spark.route.Routes"
  • Does NOT call startSpan — relies on Jetty's existing instrumentation

So the agent's choice matches the existing canonical pattern. The reviewer's spec-compliance critique appears to be applying generic HTTP-server guidance ("each framework should own its server span") that doesn't fit this library's established convention.

Reviewers familiar with SparkJava should evaluate whether the existing pattern is itself correct. If it is, this PR is functionally equivalent to the existing module and can be considered a successful toolkit reproduction. If the existing module should be refactored to create its own span, this PR has the same issue.

Test plan

  • CI builds the new module
  • CI runs :sparkjava-2.3-gen:test and :sparkjava-2.3-gen:forkedTest
  • CI runs :sparkjava-2.3-gen:muzzle
  • CI runs :sparkjava-2.3-gen:latestDepTest
  • Multi-JVM matrix (JVM 8/17/21/25) passes
  • No conflict with existing sparkjava-2.3 module (the two should coexist; we may want to disable one or pick one before merging)

Provenance

Research artifacts (agent transcript, hypothesis file, all skill changes the toolkit applied) are preserved in DataDog/apm-instrumentation-toolkit branch eval/java:

  • docs/eval-research/runs/sparkjava/attempt3-final/ — lean snapshot
  • docs/eval-research/hypotheses/sparkjava.md — hypothesis file documenting the research finding

This PR is a draft for review only — not intended for merge as-is. The duplicate module would need to be reconciled (likely by replacing the existing sparkjava-2.3 with this one, or by withdrawing) before merging.

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

❌ New Groovy Files Detected

Please avoid introducing new .groovy files to this repository.

  • dd-java-agent/instrumentation/spark/sparkjava-gen-2.3/src/test/groovy/datadog/trace/instrumentation/sparkjava/SparkJavaServer.groovy
  • dd-java-agent/instrumentation/spark/sparkjava-gen-2.3/src/test/groovy/datadog/trace/instrumentation/sparkjava/SparkJavaTest.groovy

Instead, rewrite the new file(s) in Java / JUnit. See the How to Test With JUnit Guide for more details.

If this PR needs an exception, add the tag: override-groovy-enforcement label to bypass this workflow.

@jordan-wong jordan-wong changed the title feat(sparkjava): Add sparkjava-2.3-gen module (toolkit-generated) [DO NOT MERGE] feat(sparkjava): Add sparkjava-2.3-gen module (toolkit-generated) May 11, 2026
@amarziali amarziali self-assigned this May 11, 2026
@amarziali amarziali added the tag: do not merge Do not merge changes label May 11, 2026
@jordan-wong jordan-wong self-assigned this May 11, 2026
…allel to sparkjava-2.3)

This PR adds a new module `dd-java-agent/instrumentation/spark/sparkjava-gen-2.3`
containing an alternative SparkJava 2.3 instrumentation generated by the
APM instrumentation toolkit. Placed alongside existing `sparkjava-2.3` (not
replacing it) so reviewers can compare side by side.

Module name follows dd-trace-java's instrumentation-naming convention:
{framework}-gen-{version} so the name ends with the required version suffix
(initial attempt used sparkjava-2.3-gen which would have failed the
checkInstrumentationNaming Gradle task).

## What the toolkit did

One agent-driven workflow run produced the module end-to-end. Cost: $74.72,
duration ~2.5 hours, 10 reviewer iterations.

Key choices the agent made:
- Instruments `spark.route.Routes.find()` — matches the existing `sparkjava-2.3`
  module's `RoutesInstrumentation` on `spark.route.Routes`
- Enriches the existing Jetty server span with `http.route` rather than creating
  a new span (existing module follows the same approach; Jetty is always the
  embedded server under SparkJava)
- Open-ended muzzle version range `[2.3,)` with `assertInverse = true`
- Spock tests extending `HttpServerTest`

## Verification

```
./gradlew :dd-java-agent:instrumentation:spark:sparkjava-gen-2.3:check \\
          :dd-java-agent:instrumentation:spark:sparkjava-gen-2.3:muzzle \\
          :dd-java-agent:instrumentation:spark:sparkjava-gen-2.3:latestDepTest
BUILD SUCCESSFUL in 46s
```

Multi-JVM CI matrix not run locally; standard CI will cover that.

## Reviewer notes

The toolkit's reviewer step flagged 7 TODOs across 10 iterations about
spec-compliance (suggesting `MatcherFilter.doFilter` as a target + creating
an own server span). The **existing** `sparkjava-2.3` module on master also
instruments `Routes` (not `MatcherFilter`) and relies on Jetty for span
creation — see `dd-java-agent/instrumentation/spark/sparkjava-2.3/src/main/java/datadog/trace/instrumentation/sparkjava/RoutesInstrumentation.java`.

The agent's implementation matches the canonical pattern. The reviewer's
suggestions appear to apply generic HTTP-server guidance that doesn't fit
this library's convention.

## Provenance

Generated by apm-instrumentation-toolkit (DataDog/apm-instrumentation-toolkit
branch eval/java). Research artifacts in the toolkit repo:
- docs/eval-research/runs/sparkjava/attempt3-final/
- docs/eval-research/hypotheses/sparkjava.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jordan-wong jordan-wong force-pushed the eval/sparkjava-2.3-gen-toolkit-attempt branch from 7f8bfb4 to 11a3039 Compare May 11, 2026 14:05
@jordan-wong jordan-wong changed the title [DO NOT MERGE] feat(sparkjava): Add sparkjava-2.3-gen module (toolkit-generated) [DO NOT MERGE] feat(sparkjava): Add sparkjava-gen-2.3 module (toolkit-generated) May 11, 2026
@amarziali
Copy link
Copy Markdown
Contributor

❌ New Groovy Files Detected

Please avoid introducing new .groovy files to this repository.

  • dd-java-agent/instrumentation/spark/sparkjava-gen-2.3/src/test/groovy/datadog/trace/instrumentation/sparkjava/SparkJavaServer.groovy
  • dd-java-agent/instrumentation/spark/sparkjava-gen-2.3/src/test/groovy/datadog/trace/instrumentation/sparkjava/SparkJavaTest.groovy

Instead, rewrite the new file(s) in Java / JUnit. See the How to Test With JUnit Guide for more details.

If this PR needs an exception, add the tag: override-groovy-enforcement label to bypass this workflow.

@jordan-wong we disallow new groovy files. As per our policy, new tests have to be written in java

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

Labels

tag: do not merge Do not merge changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants