Skip to content

Remove AgentTracer.noopContinuation() sentinel#12004

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
mcculls/cleanup-noop-continuation
Jul 20, 2026
Merged

Remove AgentTracer.noopContinuation() sentinel#12004
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
mcculls/cleanup-noop-continuation

Conversation

@mcculls

@mcculls mcculls commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Motivation

Call sites now check continuation.context() == Context.root() instead of comparing against a shared singleton, mirroring ThreadLocalContextManager.

This helps with switching between the two context manager approaches, since the checks now don't assume a particular implementation.

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Call sites now check continuation.context() == Context.root() instead of
comparing against a shared singleton, mirroring ThreadLocalContextManager.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mcculls mcculls added comp: core Tracer core tag: no release notes Changes to exclude from release notes labels Jul 20, 2026
@mcculls
mcculls requested a review from a team as a code owner July 20, 2026 13:34
@mcculls
mcculls requested review from a team as code owners July 20, 2026 13:34
@mcculls
mcculls requested review from Copilot, mtoffl01 and ygree and removed request for a team July 20, 2026 13:34
@dd-octo-sts dd-octo-sts Bot added the tag: ai generated Largely based on code generated by an AI or LLM label Jul 20, 2026
@mcculls

mcculls commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@datadog-prod-us1-6 datadog-prod-us1-6 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.

Datadog Autotest: PASS

More details

PR removes AgentTracer.noopContinuation() sentinel and migrates all 17 call sites to compare continuation.context() == Context.root(). The semantic change is safe: all code paths are equivalent, the @nonnull contract on captureActiveSpan() prevents NPEs, and the change actually fixes a latent bug where NoopContinuation.context() was incorrectly returning NoopSpan.INSTANCE instead of Context.root(). No regressions identified across continuation-checking patterns in async wrappers (Netty, Jetty, Undertow, MongoDB, HTTP clients).

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 0e85a14 · What is Autotest? · Any feedback? Reach out in #autotest

Copilot AI 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.

Pull request overview

This PR removes the AgentTracer.noopContinuation() sentinel and standardizes “no-op continuation” detection on continuation.context() == Context.root(), aligning behavior across context manager implementations and easing switching between them.

Changes:

  • Remove AgentTracer.noopContinuation() and update call sites to use Context.root() / Java8BytecodeBridge.rootContext() checks.
  • Update NoopContinuation to expose a public singleton and return Context.root() from context().
  • Adjust core and instrumentation tests to assert against Context.root() instead of a shared continuation instance.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/NoopContinuation.java Makes NoopContinuation publicly accessible and changes its context() to return Context.root().
internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/java/lang/ProcessImplInstrumentationHelpers.java Replaces sentinel identity check with parentContinuation.context() == Context.root().
internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentTracer.java Removes noopContinuation() API and updates internal no-op capture to use NoopContinuation.INSTANCE.
dd-trace-core/src/test/java/datadog/trace/core/scopemanager/ScopeManagerForkedTest.java Updates assertions to validate no-op continuations via Context.root().
dd-trace-core/src/main/java/datadog/trace/core/scopemanager/ContinuableScopeManager.java Switches no-op continuation return paths to reuse NoopContinuation.INSTANCE and adds Context.root() handling in capture(Context).
dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/UndertowRunnableWrapper.java Uses continuation.context() != Context.root() to decide whether to wrap.
dd-java-agent/instrumentation/synapse-3.0/src/main/java/datadog/trace/instrumentation/synapse3/SynapseServerWorkerInstrumentation.java Uses rootContext() bridge for root-context comparison in advice code.
dd-java-agent/instrumentation/synapse-3.0/src/main/java/datadog/trace/instrumentation/synapse3/SynapseClientWorkerInstrumentation.java Uses rootContext() bridge for root-context comparison in advice code.
dd-java-agent/instrumentation/spring/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpannedMethodInvocation.java Uses continuation.context() != Context.root() branching.
dd-java-agent/instrumentation/opentracing/opentracing-0.32/src/test/groovy/OpenTracing32Test.groovy Updates no-op continuation assertions to check .context() == Context.root().
dd-java-agent/instrumentation/opentracing/opentracing-0.31/src/test/groovy/OpenTracing31Test.groovy Updates no-op continuation assertions to check .context() == Context.root().
dd-java-agent/instrumentation/netty/netty-promise-4.0/src/main/java/datadog/trace/instrumentation/netty4/promise/ListenerWrapper.java Uses continuation.context() == Context.root() to skip wrapping.
dd-java-agent/instrumentation/netty/netty-4.1/src/main/java/datadog/trace/instrumentation/netty41/NettyChannelPipelineInstrumentation.java Uses rootContext() bridge comparison in advice code.
dd-java-agent/instrumentation/netty/netty-4.0/src/main/java/datadog/trace/instrumentation/netty40/NettyChannelPipelineInstrumentation.java Uses rootContext() bridge comparison in advice code.
dd-java-agent/instrumentation/netty/netty-3.8/src/main/java/datadog/trace/instrumentation/netty38/NettyChannelInstrumentation.java Uses rootContext() bridge comparison in advice code.
dd-java-agent/instrumentation/mongo/mongo-driver/mongo-driver-4.0/src/main/java/datadog/trace/instrumentation/mongo/CallbackWrapper.java Updates wrapping condition to check against root context (currently has a Context name-collision issue).
dd-java-agent/instrumentation/jetty/jetty-server/jetty-server-12.0/src/main/java17/datadog/trace/instrumentation/jetty12/JettyRunnableWrapper.java Uses continuation.context() != Context.root() to decide whether to wrap.
dd-java-agent/instrumentation/apache-httpclient/apache-httpclient-5.0/src/main/java/datadog/trace/instrumentation/apachehttpclient5/TraceContinuedFutureCallback.java Switches no-op continuation check to parentContinuation.context() == Context.root().
dd-java-agent/instrumentation/apache-httpclient/apache-httpasyncclient-4.0/src/main/java/datadog/trace/instrumentation/apachehttpasyncclient/TraceContinuedFutureCallback.java Switches no-op continuation check to parentContinuation.context() == Context.root().
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/Wrapper.java Uses continuation.context() != Context.root() to decide whether to wrap runnables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@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: 0e85a14175

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

@datadog-prod-us1-6

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jul 20, 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.88 s 13.95 s [-1.2%; +0.3%] (no difference)
startup:insecure-bank:tracing:Agent 12.88 s 13.02 s [-1.8%; -0.4%] (maybe better)
startup:petclinic:appsec:Agent 17.07 s 16.70 s [+1.2%; +3.2%] (significantly worse)
startup:petclinic:iast:Agent 16.91 s 16.96 s [-1.1%; +0.6%] (no difference)
startup:petclinic:profiling:Agent 16.66 s 16.86 s [-2.3%; -0.1%] (maybe better)
startup:petclinic:sca:Agent 16.98 s 16.86 s [-0.2%; +1.6%] (no difference)
startup:petclinic:tracing:Agent 16.15 s 15.57 s [-0.6%; +8.1%] (no difference)

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

@mcculls
mcculls requested a review from mhlidd July 20, 2026 14:49
@mcculls
mcculls added this pull request to the merge queue Jul 20, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

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

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-20 18:23:37 UTC ℹ️ Start processing command /merge


2026-07-20 18:23:41 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-20 19:32:31 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 20, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit f698857 into master Jul 20, 2026
786 of 792 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the mcculls/cleanup-noop-continuation branch July 20, 2026 19:32
@github-actions github-actions Bot added this to the 1.65.0 milestone Jul 20, 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.

3 participants