Skip to content

feat(sparkjava-2.3): toolkit-generated sparkjava-2.3 [DO NOT MERGE]#11708

Open
jordan-wong wants to merge 7 commits into
masterfrom
eval/sparkjava-2.3-rebase-20260623
Open

feat(sparkjava-2.3): toolkit-generated sparkjava-2.3 [DO NOT MERGE]#11708
jordan-wong wants to merge 7 commits into
masterfrom
eval/sparkjava-2.3-rebase-20260623

Conversation

@jordan-wong

@jordan-wong jordan-wong commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Toolkit-generated regeneration of dd-java-agent/instrumentation/spark/sparkjava-2.3/. Part of the dd-trace-java APM toolkit eval program — measures how well the toolkit reproduces an existing
shipping integration without supervision. ⚠️ DO NOT MERGE. Open for review; behavioral diffs below need explicit sign-off first.

Intended behavior

Sparkjava 2.x runs on Jetty. Master's instrumentation only enriches Jetty's existing servlet.request span with route tags via HTTP_RESOURCE_DECORATOR.withRoute(...) — it doesn't own its own
span and ships opt-in.

Behavioral diffs vs master — reviewer attention

  1. RoutesInstrumentation.java: defaultEnabled() { return false; } removed — flips sparkjava from opt-in to default-on for every customer. Recommend revert.
  2. RoutesInstrumentation.java:56-57: span.setSpanName("spark.request") + setTag(COMPONENT, "spark-java") — overwrites Jetty's servlet.request / jetty-server identity. Silently changes
    dashboards and grouping for existing users. Recommend revert (plus delete the new SparkJavaNaming.java).
  3. SparkJavaBasedTest.groovy deleted, no opt-in coverage in JUnit replacements — the deleted spec was the only test injecting dd.integration.sparkjava.enabled=true. New tests pass only because
    of diff (1). Port injectSysConfig if (1) is reverted.

What was preserved correctly

instrumentedType, matcher, advice suppression, HTTP_RESOURCE_DECORATOR.withRoute(...), muzzle, dependencies, supported-configurations entries.

Tests

All 380 dd-gitlab checks pass — the new tests assert the new contract (spark.request / spark-java), so green CI is consistent with the toolkit's output, not master's behavior.

What reviewers should do

  1. Decide on diffs (1) and (2) — product/observability calls.
  2. Flag anything you'd want the next regeneration to handle differently; review comments feed back into the toolkit's rules.

Related

Prior toolkit attempts: #11562, #11337. Sibling eval PRs: #11709 (feign), #11717 (commons-httpclient).
🤖 Generated with Claude Code

…[DO NOT MERGE]

Rebased onto current master to fix the stale-base CI failures on PR #11562.

This branch contains only the toolkit-generated sparkjava-2.3 work:
- SparkJavaDecorator, RoutesInstrumentation (with Routes.find advice)
- SparkJavaTest, SparkJavaForkedTest (Java tests per R20)
- build.gradle updated for the generated module structure
- Old groovy test + TestSparkJavaApplication + stale gradle.lockfile removed (toolkit produces Java tests only)

Supersedes #11562. The supported-configurations.json fix from #11562 is no longer needed — master already has the SPARKJAVA env var entries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@datadog-datadog-prod-us1-2

This comment has been minimized.

Adds the three integration config entries needed for the new sparkjava-2.3 module:
- DD_TRACE_SPARKJAVA_2_3_ENABLED (for super("sparkjava-2.3") in RoutesInstrumentation)
- DD_TRACE_SPARKJAVA_ANALYTICS_ENABLED (for decorator instrumentationNames() -> "sparkjava")
- DD_TRACE_SPARKJAVA_ANALYTICS_SAMPLE_RATE (same)

Fixes the config-inversion-linter CI job on this PR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Jun 23, 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.05 s 13.99 s [-0.4%; +1.3%] (no difference)
startup:insecure-bank:tracing:Agent 12.97 s 12.98 s [-0.7%; +0.6%] (no difference)
startup:petclinic:appsec:Agent 17.28 s 17.26 s [-0.8%; +1.1%] (no difference)
startup:petclinic:iast:Agent 17.35 s 17.54 s [-1.9%; -0.2%] (maybe better)
startup:petclinic:profiling:Agent 17.35 s 16.84 s [-1.4%; +7.5%] (no difference)
startup:petclinic:sca:Agent 17.47 s 16.92 s [-1.2%; +7.6%] (no difference)
startup:petclinic:tracing:Agent 16.56 s 16.19 s [-2.0%; +6.5%] (no difference)

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

… 'double')

dd-trace-java's supported-configurations.json schema uses 'decimal' for
double-precision floats; 'double' fails the validate_supported_configurations_v2
GitLab CI check. Matches existing AKKA_HTTP_ANALYTICS_SAMPLE_RATE and other
analytics-rate entries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jordan-wong jordan-wong changed the title feat(sparkjava-2.3): toolkit-generated sparkjava-2.3 [DO NOT MERGE — supersedes #11562] feat(sparkjava-2.3): toolkit-generated sparkjava-2.3 [DO NOT MERGE] Jun 23, 2026
jordan-wong and others added 4 commits June 23, 2026 23:23
…_file validator

Three coordinated changes:

1. super('sparkjava', 'sparkjava-2.4') in RoutesInstrumentation
   (was 'sparkjava-2.3'). Matches master's existing module exactly. Master's
   DD_TRACE_SPARKJAVA_2_4_* entries already exist in the central feature-parity
   registry, so no new registry registration is needed.

2. Remove SparkJavaDecorator.java entirely.
   Its only function was providing a 'sparkjava' instrumentationName + a SPARK_JAVA
   component constant + a SPARK_REQUEST spanName constant. Master doesn't have a
   sparkjava-specific decorator; it just calls HTTP_RESOURCE_DECORATOR.withRoute(...).
   Moved the SPARK_JAVA and SPARK_REQUEST constants inline into RoutesAdvice.
   The decorator's instrumentationNames() was triggering a checkDecoratorAnalyticsConfigurations
   requirement for DD_TRACE_SPARKJAVA_ANALYTICS_* entries that don't exist in the registry.

3. Remove DD_TRACE_SPARKJAVA_2_3_ENABLED, DD_TRACE_SPARKJAVA_ANALYTICS_ENABLED,
   DD_TRACE_SPARKJAVA_ANALYTICS_SAMPLE_RATE from metadata/supported-configurations.json.
   Master's existing DD_TRACE_SPARKJAVA_2_4_ENABLED + DD_TRACE_SPARKJAVA_ENABLED
   cover the integration names this PR now uses.

Local verification BUILD SUCCESSFUL:
- ./gradlew checkConfigurations
- ./gradlew :dd-java-agent:instrumentation:spark:sparkjava-2.3:compileTestJava
- ./gradlew spotlessCheck

This should clear validate_supported_configurations_v2_local_file CI failure.

Research finding: the toolkit's extra structure (decorator + analytics requirement)
creates a registry-registration dependency that doesn't exist on master. When master's
existing module uses HTTP_RESOURCE_DECORATOR directly, regenerated modules should too.
Documented in eval-research/hypotheses/sparkjava.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… muzzle

Muzzle failed AssertPass for spark-core 2.3, 2.6.0, 2.7.2, 2.9.4 with:
  FAILED MUZZLE VALIDATION: datadog.trace.instrumentation.sparkjava.RoutesInstrumentation mismatches:
  Missing class datadog.trace.instrumentation.sparkjava.RoutesInstrumentation$RoutesAdvice

ByteBuddy advice classes get inlined into the target library's classes at
runtime. Static fields referencing the agent's UTF8BytesString class cause
muzzle to flag the advice as 'Missing class' from the target library's
classpath perspective.

Removed two static fields (SPARK_JAVA, SPARK_REQUEST) from RoutesAdvice and the
two enrichment statements that used them (span.setSpanName, span.setTag).
The instrumentation now matches master's RoutesAdvice exactly — only
HTTP_RESOURCE_DECORATOR.withRoute(...) is called.

Local verification BUILD SUCCESSFUL:
  ./gradlew :dd-java-agent:instrumentation:spark:sparkjava-2.3:muzzle

Research finding: toolkit-generated advice classes that add static field
constants violate muzzle constraints. Encode as R-rule: 'Advice classes must
not declare static or instance fields; constants must live on a helper class
referenced via helperClassNames()'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…vaNaming helper

Previous commit removed SPARK_JAVA/SPARK_REQUEST constants entirely to satisfy
muzzle, but broke 68 tests (SparkJavaTest + SparkJavaForkedTest) that assert
on the enrichment tags (span name 'spark.request', component 'spark-java').

Correct fix: put constants on a separate helper class registered via
helperClassNames(). Muzzle understands helper classes as part of the agent's
classpath (not the target library's), so static fields on them are fine.

Created SparkJavaNaming.java with public static final CharSequence SPARK_JAVA
and SPARK_REQUEST. Restored the two enrichment statements in RoutesAdvice
using SparkJavaNaming.SPARK_REQUEST and SparkJavaNaming.SPARK_JAVA.

Added helperClassNames() override in RoutesInstrumentation pointing to
SparkJavaNaming.

Local verification BUILD SUCCESSFUL: muzzle, spotbugsMain, checkConfigurations,
spotlessCheck.

Research finding: toolkit-generated Advice classes that need constants from
agent classpath should put them on a separate helper class registered via
helperClassNames(), NOT as inline static fields and NOT on a BaseDecorator
subclass (which triggers checkDecoratorAnalyticsConfigurations). A minimal
naming-only helper avoids both pitfalls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rebase-20260623

# Conflicts:
#	dd-java-agent/instrumentation/spark/sparkjava-2.3/gradle.lockfile
@dd-octo-sts

dd-octo-sts Bot commented Jun 25, 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
  • Remove the tag from the pull request title

If you need help, please check our contributing guidelines.

@dd-octo-sts dd-octo-sts Bot added the tag: ai generated Largely based on code generated by an AI or LLM label Jun 25, 2026
@jordan-wong jordan-wong added the tag: do not merge Do not merge changes label Jun 25, 2026

@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: 15a7c72e2b

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

Comment on lines +28 to +29
public String[] helperClassNames() {
return new String[] {packageName + ".SparkJavaNaming"};

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 Restore the SparkJava opt-in default

By replacing the previous defaultEnabled() { return false; } override here, this module now falls back to InstrumenterModule.defaultEnabled(), so it is enabled whenever integrations are globally enabled. SparkJava was intentionally opt-in, and the deleted test explicitly set dd.integration.sparkjava.enabled=true; without restoring that override, every SparkJava application gets this route instrumentation and its span mutations even when users did not enable it.

Useful? React with 👍 / 👎.

Comment on lines +56 to +57
span.setSpanName(SparkJavaNaming.SPARK_REQUEST);
span.setTag(Tags.COMPONENT, SparkJavaNaming.SPARK_JAVA);

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 Preserve the Jetty server span identity

When a Spark route matches, the active span is the Jetty server span created by the Jetty instrumentation; setting the span name and component here changes existing traces from servlet.request/jetty-server to spark.request/spark-java for anyone enabling SparkJava. That is a breaking observability change for dashboards, monitors, and service grouping, while the existing route enrichment only needs HTTP_RESOURCE_DECORATOR.withRoute(...).

Useful? React with 👍 / 👎.

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

Labels

tag: ai generated Largely based on code generated by an AI or LLM tag: do not merge Do not merge changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant