Skip to content

Restore instrumentation contexts without legacy scope APIs - #13454

Open
mcculls wants to merge 9 commits into
masterfrom
mcculls/cleanup-unscoped-contexts
Open

mcculls wants to merge 9 commits into
masterfrom
mcculls/cleanup-unscoped-contexts

Conversation

@mcculls

@mcculls mcculls commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Restore the previous context after CI Visibility tests and suites, Karate steps, and AWS SDK requests when using the non-legacy context manager. Hand Mongo command spans to the command listener without activating them, and finish pending spans that the listener never claims.

Warn once when OpenTracing callers attempt to close the deprecated active-scope view instead of the scope returned by activation.

Motivation

Continue the migration away from legacy scope activation and closure semantics. Give these integrations explicit ownership of context restoration while preserving their legacy paths, and remove the static AgentTracer helpers for legacy activation and closure.

Additional Notes

Review decisions

  • OpenTracing: ScopeManager.active() was deprecated seven years ago in OpenTracing 0.32.0. With the non-legacy manager, closing this view leaves the context intact and logs a warning once. Callers should close the scope returned by activation. Legacy closure behavior is preserved.
  • Migration boundaries: Keep context-manager compatibility choices local during the migration. Some duplication is acceptable; introducing shared helpers solely to remove it would add temporary abstractions and potential coupling or performance costs before the legacy paths are removed.
  • Test conventions: Retain the existing convention of literal timeout budgets and use @AfterEach for the Karate veto-handler cleanup. Wrapping most of each test body in try/finally would reduce readability without addressing a demonstrated failure. Configuration annotations use existing key constants and inherit shared superclass settings.
  • Mongo scope: This change addresses span handoff and the existing pending-span leak. Extending error capture for async callback failures before command-start notification is outside this migration's scope; it would require separate investigation and instrumentation changes.

@mcculls mcculls added tag: no release notes Changes to exclude from release notes type: refactoring comp: context propagation Trace context propagation tag: ai generated Largely based on code generated by an AI or LLM labels Nov 13, 2026
@mcculls
mcculls added this pull request to stack #13397 November 13, 2026 22:47
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🎯 Code Coverage (details)
• Patch Coverage: 92.21%
• Overall Coverage: 59.81% (-1.54%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c43d6ff | Docs | Give us feedback!

@pr-commenter

pr-commenter Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Debugger benchmarks

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
ci_job_date 1794780659 1794780975
end_time 2026-11-15T22:12:27 2026-11-15T22:17:43
git_branch master mcculls/cleanup-unscoped-contexts
git_commit_sha e8e4235 ffe2e21
start_time 2026-11-15T22:11:00 2026-11-15T22:16:16
See matching parameters
Baseline Candidate
ci_job_id 2255929530 2255929530
ci_pipeline_id 153369329 153369329
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
git_commit_date 1794779748 1794779748

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 9 metrics, 6 unstable metrics.

See unchanged results
scenario Δ mean agg_http_req_duration_min Δ mean agg_http_req_duration_p50 Δ mean agg_http_req_duration_p75 Δ mean agg_http_req_duration_p99 Δ mean throughput
scenario:noprobe unstable
[-19.750µs; +22.274µs] or [-6.261%; +7.062%]
unstable
[-33288.697ns; +33472.163ns] or [-9.547%; +9.599%]
unstable
[-43079.114ns; +42355.580ns] or [-11.862%; +11.663%]
unstable
[-130.460µs; +68.223µs] or [-11.007%; +5.756%]
same
scenario:basic same same same unstable
[-128.505µs; +119.332µs] or [-11.277%; +10.472%]
unstable
[-123.470op/s; +123.470op/s] or [-5.309%; +5.309%]
scenario:loop same same same same same
Request duration reports for reports
gantt
    title reports - request duration [CI 0.99] : candidate=None, baseline=None
    dateFormat X
    axisFormat %s
section baseline
noprobe (348.691 µs) : 317, 381
.   : milestone, 349,
basic (321.812 µs) : 317, 327
.   : milestone, 322,
loop (7.57 ms) : 7564, 7576
.   : milestone, 7570,
section candidate
noprobe (348.782 µs) : 317, 380
.   : milestone, 349,
basic (322.486 µs) : 317, 328
.   : milestone, 322,
loop (7.57 ms) : 7564, 7576
.   : milestone, 7570,
Loading
  • baseline results
Scenario Request median duration [CI 0.99]
noprobe 348.691 µs [316.621 µs, 380.761 µs]
basic 321.812 µs [316.523 µs, 327.101 µs]
loop 7.57 ms [7.564 ms, 7.576 ms]
  • candidate results
Scenario Request median duration [CI 0.99]
noprobe 348.782 µs [317.426 µs, 380.139 µs]
basic 322.486 µs [317.12 µs, 327.852 µs]
loop 7.57 ms [7.564 ms, 7.576 ms]

@dd-octo-sts

dd-octo-sts Bot commented Nov 13, 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.92 s 14.80 s [+0.1%; +1.6%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.76 s 13.85 s [-1.4%; +0.2%] (no difference)
startup:petclinic:appsec:Agent 17.18 s 17.21 s [-1.0%; +0.7%] (no difference)
startup:petclinic:iast:Agent 16.91 s 17.12 s [-2.1%; -0.4%] (maybe better)
startup:petclinic:profiling:Agent 16.68 s 16.22 s [-1.5%; +7.2%] (no difference)
startup:petclinic:sca:Agent 17.18 s 16.97 s [+0.6%; +2.0%] (maybe worse)
startup:petclinic:tracing:Agent 15.87 s 16.34 s [-7.0%; +1.3%] (no difference)

Commit: c43d6ff6 · 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 force-pushed the mcculls/cleanup-unscoped-contexts branch from 6f92b15 to 065a236 Compare November 14, 2026 20:18
@pr-commenter

pr-commenter Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch mcculls/remove-deprecated-instrumentation-static-methods mcculls/cleanup-unscoped-contexts
git_commit_date 1795636767 1795636769
git_commit_sha 9728ceb 5ad9c27
See matching parameters
Baseline Candidate
ci_job_date 1795637892 1795637892
ci_job_id 2302702350 2302702350
ci_pipeline_id 156575944 156575944
cpu_model Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-kdrmr6p8 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-kdrmr6p8 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaProduceBenchmark.benchProduce same

@pr-commenter

pr-commenter Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch mcculls/remove-deprecated-instrumentation-static-methods mcculls/cleanup-unscoped-contexts
git_commit_date 1795636767 1795636769
git_commit_sha 9728ceb 5ad9c27
See matching parameters
Baseline Candidate
ci_job_date 1795637936 1795637936
ci_job_id 2302702351 2302702351
ci_pipeline_id 156575944 156575944
cpu_model Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-nujw1evi 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-nujw1evi 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaConsumerBenchmark.benchConsume same

@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch from 065a236 to 3d8e54f Compare November 15, 2026 14:21
@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch 2 times, most recently from b668a33 to ffe2e21 Compare November 15, 2026 21:59
@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch from ffe2e21 to f3d5901 Compare November 16, 2026 23:56
@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch from f3d5901 to 54d3643 Compare November 18, 2026 19:48
@mcculls
mcculls removed this pull request from stack #13397 November 19, 2026 09:27
@mcculls
mcculls added this pull request to stack #13545 November 19, 2026 09:27
@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch from 54d3643 to c58fbaa Compare November 20, 2026 17:48
@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch from c58fbaa to dbe14d7 Compare November 20, 2026 21:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T20:07:16.913652Z ea3a5d6 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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.

Bits Code Review: PASS

More details

Static coverage assessed context restoration, Mongo span ownership, and OpenTracing compatibility paths. Runtime behavior remains unverified because tests were not executed and production validation was excluded.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit ea3a5d6

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot force-pushed the mcculls/cleanup-unscoped-contexts branch from ea3a5d6 to 5ad9c27 Compare November 25, 2026 19:59

@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.

Bits Code Review: PASS

More details

Closing OpenTracing’s deprecated active-scope view intentionally leaves non-legacy context intact; callers must close the scope returned by activation. Runtime behavior and human PR discussion remain unverified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 5ad9c27

Base automatically changed from mcculls/remove-deprecated-instrumentation-static-methods to master November 26, 2026 17:19
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot requested a review from a team as a code owner November 26, 2026 17:19
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot force-pushed the mcculls/cleanup-unscoped-contexts branch from 5ad9c27 to 492e3f8 Compare November 26, 2026 17:19

@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.

Bits Code Review: PASS

More details

Static review identified no reportable issue in context restoration or Mongo span handoff. Runtime behavior under the legacy and non-legacy context managers was not exercised.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 492e3f8

@mcculls
mcculls requested a review from cecile75 November 26, 2026 18:50
@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch from 2b301df to 70a7230 Compare November 27, 2026 09:24

@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.

Bits Code Review: PASS

More details

The static reviewer identified no actionable defects. AWS dependency-version compatibility was assessed from repository evidence only, and runtime behavior remains unverified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 70a7230

@genesor genesor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM !

@gh-worker-ownership-write-b05516
gh-worker-ownership-write-b05516 Bot removed the request for review from a team November 27, 2026 18:21
…sure

Remove the static activateSpanWithoutScope and closeActive helpers and
route callers through TracerAPI. Categorize the retained instance
methods as deprecated scope management supported only in legacy mode.
@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch from daeeec1 to dada4be Compare November 27, 2026 18:30

@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.

Bits Code Review: PASS

More details

Closing OpenTracing’s deprecated active-scope view intentionally preserves the non-legacy context; callers must close the scope returned by activation. Static inspection found no actionable defects, but runtime restoration behavior was not exercised.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit dada4be

@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch from dada4be to 4becd5d Compare November 27, 2026 18:43
Save and restore test, suite, and Karate step contexts with context handles.
Keep nested CI activations restorable when they end out of order, clean up
vetoed Karate steps, and preserve cold-start retry instrumentation.

Include context restoration, step veto, and cold-start retry regressions.
Restore AWS SDK v1 request contexts at execution exit and keep SDK v2
legacy scope advice separate from context restoration advice. Preserve
async signing contexts and retain the legacy scope lifecycle.

Include request restoration, async signing, missing-context, and legacy
client regressions.
Use MongoPendingSpan to hand command spans from connection advice to the
command listener without changing the active context. Create a command
span when no pending span is available and inject the helper into all
supported driver instrumentation modules.

Include helper and async DBM handoff regressions for both context managers,
with the corresponding test suite configuration and dependency locks.
Keep ScopeManager.active().close() as an active-span view in non-legacy
mode and warn once that callers must close the scope returned by activate.
Preserve legacy closure and strict-mode checks across both instrumented
OpenTracing versions and the compatibility library.

Include active-view closure regressions for all three implementations.

@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.

Bits Code Review: PASS

More details

Static review identified no actionable defects in context restoration or Mongo span handoff. Runtime tests were not executed, and production telemetry was explicitly excluded.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 4becd5d

@mcculls
mcculls force-pushed the mcculls/cleanup-unscoped-contexts branch from 4becd5d to c43d6ff Compare November 27, 2026 18:53

@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.

Bits Code Review: PASS

More details

The static review found no actionable defects in context restoration or span handoff. Closing OpenTracing’s deprecated active-scope view intentionally leaves the context intact under the non-legacy manager; callers must close the scope returned by activation.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit c43d6ff

This branch has not been deployed

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

Labels

comp: context propagation Trace context propagation tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes tag: override pr size check Override the "pull request size" check type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants