Skip to content

Fix flaky PayloadDispatcherImplTest by stubbing getRootSpan#11873

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
alexeyk/fix-payload-dispatcher-flaky-test
Jul 7, 2026
Merged

Fix flaky PayloadDispatcherImplTest by stubbing getRootSpan#11873
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
alexeyk/fix-payload-dispatcher-flaky-test

Conversation

@AlexeyKuznetsov-DD

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Stubs getRootSpan() on the PendingTrace stub in PayloadDispatcherImplTest.realSpan() so it returns the real span instead of letting Spock fabricate a dummy on every call.

Motivation

The test flush automatically when data limit is breached was flaky on CI with SpockTimeoutError: Method timed out after 10.00 seconds.

getRootSpan() returns DDSpan (a concrete class with no no-arg constructor). Since it was left unstubbed, every serialization pass in the tight while (!flushed.get()) loop hit Spock's EmptyOrDummyResponse, which tried Class.newInstance() (→ InstantiationException) and fell back to expensive reflection/ByteBuddy. Accumulated across all iterations, this intermittently blew the 10s @Timeout on loaded CI runners.

Additional Notes

Behavior is unchanged: the span is a single-span trace, so it is its own root — getRootSpanContextIfDifferent() still resolves to this. The fix just removes the per-call reflection cost, making the loop fast and deterministic.

Test failed on CI with the following stack trace:

org.spockframework.runtime.SpockTimeoutError: Method timed out after 10.00 seconds

Method timed out after 10.00 seconds
	at java.base@11.0.31/java.lang.Throwable.fillInStackTrace(Throwable.java:787)
	at java.base@11.0.31/java.lang.Throwable.<init>(Throwable.java:270)
	at java.base@11.0.31/java.lang.Exception.<init>(Exception.java:66)
	at java.base@11.0.31/java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:56)
	at java.base@11.0.31/java.lang.InstantiationException.<init>(InstantiationException.java:63)
	at java.base@11.0.31/java.lang.Class.newInstance(Class.java:571)
	at app//org.spockframework.mock.EmptyOrDummyResponse.createEmptyObject(EmptyOrDummyResponse.java:141)
	at app//org.spockframework.mock.EmptyOrDummyResponse.respond(EmptyOrDummyResponse.java:117)
	at app//org.spockframework.mock.IResponseGenerator.lambda$getResponseSupplier$0(IResponseGenerator.java:67)
	at app//org.spockframework.mock.runtime.MockController.handle(MockController.java:60)
	at app//org.spockframework.mock.runtime.JavaMockInterceptor.intercept(JavaMockInterceptor.java:83)
	at app//org.spockframework.mock.runtime.ByteBuddyInterceptorAdapter.interceptNonAbstract(ByteBuddyInterceptorAdapter.java:35)
	at app//datadog.trace.core.DDSpanContext.getRootSpanContextIfDifferent(DDSpanContext.java:584)
	at app//datadog.trace.core.DDSpanContext.getRootSpanContextOrThis(DDSpanContext.java:578)
	at app//datadog.trace.core.DDSpanContext.getSamplingPriority(DDSpanContext.java:644)
	at app//datadog.trace.core.DDSpanContext.processTagsAndBaggage(DDSpanContext.java:1243)
	at app//datadog.trace.core.DDSpanContext.processTagsAndBaggage(DDSpanContext.java:1198)
	at app//datadog.trace.core.DDSpan.processTagsAndBaggage(DDSpan.java:780)
	at app//datadog.trace.common.writer.ddagent.TraceMapperV0_5.map(TraceMapperV0_5.java:82)
	at app//datadog.trace.common.writer.ddagent.TraceMapperV0_5.map(TraceMapperV0_5.java:29)
	at app//datadog.communication.serialization.msgpack.MsgPackWriter.format(MsgPackWriter.java:84)
	at app//datadog.trace.common.writer.PayloadDispatcherImpl.addTrace(PayloadDispatcherImpl.java:71)
	at datadog.trace.common.writer.PayloadDispatcherImplTest.flush automatically when data limit is breached(PayloadDispatcherImplTest.groovy:46)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@AlexeyKuznetsov-DD AlexeyKuznetsov-DD self-assigned this Jul 6, 2026
@AlexeyKuznetsov-DD AlexeyKuznetsov-DD added comp: core Tracer core tag: no release notes Changes to exclude from release notes tag: flaky test Flaky tests labels Jul 6, 2026
@AlexeyKuznetsov-DD AlexeyKuznetsov-DD marked this pull request as ready for review July 6, 2026 23:11
@AlexeyKuznetsov-DD AlexeyKuznetsov-DD requested a review from a team as a code owner July 6, 2026 23:11
@dd-octo-sts dd-octo-sts Bot added the tag: ai generated Largely based on code generated by an AI or LLM label Jul 6, 2026
@datadog-prod-us1-4

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 76.69% (+19.76%)

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

@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 14.80 s 14.72 s [-0.6%; +1.6%] (no difference)
startup:insecure-bank:tracing:Agent 13.64 s 13.67 s [-1.0%; +0.6%] (no difference)
startup:petclinic:appsec:Agent 17.50 s 17.10 s [+1.3%; +3.4%] (significantly worse)
startup:petclinic:iast:Agent 16.78 s 17.51 s [-8.5%; +0.2%] (no difference)
startup:petclinic:profiling:Agent 17.17 s 17.34 s [-2.1%; +0.1%] (no difference)
startup:petclinic:sca:Agent 17.50 s 17.37 s [-0.1%; +1.7%] (no difference)
startup:petclinic:tracing:Agent 16.42 s 16.23 s [-3.3%; +5.6%] (no difference)

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

@AlexeyKuznetsov-DD

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

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

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-07 13:01:07 UTC ℹ️ Start processing command /merge


2026-07-07 13:01:11 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-07 14:04:49 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 32c13ee into master Jul 7, 2026
599 of 604 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the alexeyk/fix-payload-dispatcher-flaky-test branch July 7, 2026 14:04
@github-actions github-actions Bot added this to the 1.64.0 milestone Jul 7, 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: flaky test Flaky tests tag: no release notes Changes to exclude from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants