Skip to content

Remove AgentTracer.noopScope() sentinel from advice call sites#12010

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
mcculls/cleanup-noop-scope-in-advice
Jul 21, 2026
Merged

Remove AgentTracer.noopScope() sentinel from advice call sites#12010
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
mcculls/cleanup-noop-scope-in-advice

Conversation

@mcculls

@mcculls mcculls commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Replace noopScope() with null where the returned scope has no observable side effects to preserve.

Motivation

Further step towards being able to completely remove the noopScope() sentinel

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Replace noopScope() with null where the returned scope has no observable side effects to preserve.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mcculls
mcculls requested review from a team as code owners July 20, 2026 21:15
@mcculls mcculls added the comp: core Tracer core label Jul 20, 2026
@mcculls
mcculls removed the request for review from a team July 20, 2026 21:15
@mcculls mcculls added the tag: no release notes Changes to exclude from release notes label Jul 20, 2026
@mcculls
mcculls requested a review from mhlidd July 20, 2026 21:15
@mcculls
mcculls requested review from ValentinZakharov and removed request for a team July 20, 2026 21:15
@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
setRoute(routingContext);
}
try (final ContextScope scope = span != null ? activateSpan(span) : noopScope()) {
try (final ContextScope scope = span != null ? activateSpan(span) : null) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this is safe - try-with-resources allows use of null without causing an NPE

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

Copy link
Copy Markdown
Contributor

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

All five changed files are safe mechanical refactors: replacing noopScope() (which returns the NoopScope.INSTANCE singleton whose close() is empty {}) with null at call sites that only ever called close(). Java's try-with-resources explicitly handles null resources without NPE per JLS 14.20.3, and the identical … : null pattern is already used in tibco-businessworks and grizzly-client. The noopScope() method itself is preserved for identity-comparison callers (ContinuableScopeManager, TypeConverter, RedisFutureSendAdvice) that are not touched by this PR.

Was this helpful? React 👍 or 👎

📊 Validated against 3 scenarios · Open Bits AI session

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

@datadog-datadog-prod-us1-2

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 14.00 s 14.01 s [-0.8%; +0.8%] (no difference)
startup:insecure-bank:tracing:Agent 13.02 s 13.08 s [-1.7%; +0.7%] (no difference)
startup:petclinic:appsec:Agent 16.91 s 16.72 s [+0.1%; +2.2%] (maybe worse)
startup:petclinic:iast:Agent 16.86 s 16.93 s [-1.2%; +0.3%] (no difference)
startup:petclinic:profiling:Agent 16.87 s 16.17 s [-0.2%; +8.9%] (no difference)
startup:petclinic:sca:Agent 16.91 s 16.80 s [-0.3%; +1.6%] (no difference)
startup:petclinic:tracing:Agent 16.09 s 16.18 s [-1.8%; +0.7%] (no difference)

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

if (channelSpan == null || channelSpan == activeSpan()) {
// don't modify the scope
return noopScope();
return null;

@mcculls mcculls Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note returning noopScope() had no effect on the active scope (unlike activating noopSpan) - so returning null instead has the same behaviour, and matches the convention in the rest of the codebase.

@mcculls
mcculls requested a review from PerfectSlayer July 21, 2026 07:23
@mcculls
mcculls added this pull request to the merge queue Jul 21, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

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

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-21 07:28:14 UTC ℹ️ Start processing command /merge


2026-07-21 07:28:19 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-21 08:23:46 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 21, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 4a5a1e2 into master Jul 21, 2026
591 of 597 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the mcculls/cleanup-noop-scope-in-advice branch July 21, 2026 08:23
@github-actions github-actions Bot added this to the 1.65.0 milestone Jul 21, 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.

2 participants