Remove AgentTracer.noopContinuation() sentinel#12004
Remove AgentTracer.noopContinuation() sentinel#12004gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
Conversation
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>
|
@codex review |
There was a problem hiding this comment.
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).
🤖 Datadog Autotest · Commit 0e85a14 · What is Autotest? · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
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 useContext.root()/Java8BytecodeBridge.rootContext()checks. - Update
NoopContinuationto expose a public singleton and returnContext.root()fromcontext(). - 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.
There was a problem hiding this comment.
💡 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".
This comment has been minimized.
This comment has been minimized.
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
f698857
into
master
Motivation
Call sites now check
continuation.context() == Context.root()instead of comparing against a shared singleton, mirroringThreadLocalContextManager.This helps with switching between the two context manager approaches, since the checks now don't assume a particular implementation.
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]