Skip to content

chore(compat): MAX_PY=3.14 last-supported, wrap fail-closes at 3.16 (PROF-14439) - #19928

Draft
vlad-scherbich wants to merge 21 commits into
mainfrom
vlad/py315-current-py-version
Draft

chore(compat): MAX_PY=3.14 last-supported, wrap fail-closes at 3.16 (PROF-14439)#19928
vlad-scherbich wants to merge 21 commits into
mainfrom
vlad/py315-current-py-version

Conversation

@vlad-scherbich

@vlad-scherbich vlad-scherbich commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

Delta vs #19906.

MAX_PY is (3, 14) — last officially supported, matching requires-python <3.15. NEXT_MAX_PY is (3, 15). wrap/lazy stay live on 3.15 and fail-close at 3.16, not at NEXT_MAX_PY. PY_315_VERSION_INFO is the CPython API floor and is not aliased to MAX_PY.

This PR does not widen requires-python.

Layer Meaning Which PR
Compiled into artifact n/a
Armed at runtime wrap() live on 3.15; fail-close at 3.16 this PR
Observable in product/Python MAX_PY=3.14, NEXT_MAX_PY=3.15, PY_315 floor this PR

Testing

Constants pin MAX_PY=(3, 14), NEXT_MAX_PY=(3, 15), PY_315=(3, 15). wrap() monkeypatch pins fail-close at 3.16.

Risks

None.

Additional Notes

Official do-not-merge line is #19995#19996.

No release note: internal constants, changelog/no-changelog.

@vlad-scherbich vlad-scherbich added the changelog/no-changelog A changelog entry is not required for this PR. label Aug 28, 2026
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 28, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 3 circular imports that already exist on the base branch and have not been changed by this PR.

ddtrace.llmobs -> ddtrace.llmobs._evaluators -> ddtrace.llmobs._evaluators.format -> ddtrace.llmobs._experiment -> ddtrace.llmobs
ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector
ddtrace.appsec._asm_request_context -> ddtrace.appsec._iast._iast_request_context_base -> ddtrace.appsec._iast._iast_env -> ddtrace.appsec._iast.reporter -> ddtrace.appsec._exploit_prevention.stack_traces -> ddtrace.appsec._asm_request_context

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 28, 2026

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 230 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 230 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=134)
ddtrace.llmobs._integrations.pydantic_ai -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.llmobs._integrations.base -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.internal.opentelemetry.span -×-> ddtrace.trace  (product:opentelemetry -> product:tracing, score=132)
ddtrace.debugging._debugger -×-> ddtrace.trace  (product:debugging -> product:tracing, score=132)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against vlad/py315-riotfile using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

ddtrace/internal/bytecode_injection/__init__.py                         @DataDog/apm-core-python
ddtrace/internal/compat.py                                              @DataDog/python-guild @DataDog/apm-core-python
ddtrace/internal/coverage/instrumentation_py3_12.py                     @DataDog/ci-app-libraries
ddtrace/internal/lazy.py                                                @DataDog/apm-core-python
ddtrace/internal/monitoring.py                                          @DataDog/apm-core-python
ddtrace/internal/wrapping/__init__.py                                   @DataDog/apm-core-python
ddtrace/internal/wrapping/asyncs.py                                     @DataDog/apm-core-python
ddtrace/internal/wrapping/context.py                                    @DataDog/apm-core-python
ddtrace/internal/wrapping/generators.py                                 @DataDog/apm-core-python
tests/internal/test_py315_import_degrade.py                             @DataDog/apm-core-python

@vlad-scherbich
vlad-scherbich force-pushed the vlad/py315-manylinux-wheels branch from dff1fad to 1d382ed Compare August 28, 2026 14:57
@vlad-scherbich
vlad-scherbich force-pushed the vlad/py315-current-py-version branch from 9be2db6 to b142960 Compare August 28, 2026 15:04
@vlad-scherbich
vlad-scherbich changed the base branch from vlad/py315-manylinux-wheels to vlad/py315-riotfile August 28, 2026 15:04
@pr-commenter

pr-commenter Bot commented Aug 28, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-02 20:47:37

Comparing candidate commit 5b7eaa7 in PR branch vlad/py315-current-py-version with baseline commit 1b2e241 in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 7 performance regressions! Performance is the same for 575 metrics, 10 unstable metrics, 2 known flaky benchmarks, 16 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:httppropagationextract-tracecontext_headers

  • 🟥 execution_time [+2.331µs; +2.580µs] or [+7.237%; +8.010%]

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+2.409µs; +2.613µs] or [+14.460%; +15.689%]

scenario:iastaspects-rstrip_aspect

  • 🟥 execution_time [+72.512µs; +81.563µs] or [+19.230%; +21.631%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+109.970µs; +117.818µs] or [+27.788%; +29.771%]

scenario:otelspan-start

  • 🟥 execution_time [+2.314ms; +3.329ms] or [+7.344%; +10.564%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+564.637ns; +611.219ns] or [+20.853%; +22.573%]

scenario:tracer-small

  • 🟥 execution_time [+41.565µs; +43.295µs] or [+12.822%; +13.356%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:coreapiscenario-context_with_data_listeners

  • unstable execution_time [-705.033ns; +784.762ns] or [-6.360%; +7.079%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-33.955ns; +31.430ns] or [-5.561%; +5.148%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1661.794ns; +1621.519ns] or [-9.808%; +9.570%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1258.799ns; +1206.943ns] or [-9.693%; +9.294%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-319.779ns; +328.369ns] or [-8.775%; +9.011%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-252.746ns; +253.651ns] or [-8.706%; +8.737%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-80.051ns; +66.856ns] or [-7.062%; +5.898%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3957.000ns; +4054.918ns] or [-9.654%; +9.893%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-813.024ns; +740.543ns] or [-10.046%; +9.151%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-54708.486ns; +54717.606ns] or [-9.512%; +9.514%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:iastaspects-swapcase_aspect

  • 🟥 execution_time [+37.111µs; +43.814µs] or [+13.299%; +15.701%]

scenario:span-start

  • 🟥 execution_time [+1.796ms; +1.969ms] or [+12.946%; +14.192%]

Known flaky benchmarks without significant changes:

  • scenario:errortrackingflasksqli-baseline
  • scenario:flasksimple-iast-get
  • scenario:iastaspects-casefold_aspect
  • scenario:iastaspects-casefold_noaspect
  • scenario:iastaspects-index_aspect
  • scenario:iastaspects-ljust_noaspect
  • scenario:iastaspects-lower_aspect
  • scenario:iastaspects-replace_aspect
  • scenario:iastaspects-title_noaspect
  • scenario:iastaspects-translate_aspect
  • scenario:iastaspects-translate_noaspect
  • scenario:iastaspects-upper_noaspect
  • scenario:packagespackageforrootmodulemapping-cache_off
  • scenario:packagespackageforrootmodulemapping-cache_on
  • scenario:sethttpmeta-all-enabled
  • scenario:telemetryaddmetric-record-100-metrics

@vlad-scherbich
vlad-scherbich force-pushed the vlad/py315-current-py-version branch from b142960 to a2f5c63 Compare August 28, 2026 15:51
@vlad-scherbich
vlad-scherbich force-pushed the vlad/py315-current-py-version branch from a2f5c63 to 3f0ff70 Compare August 28, 2026 16:07
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Aug 28, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 5 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | contrib/gunicorn 5/6 — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | contrib/loguru 1/1 — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | contrib/mariadb 5/7

View more details · View in GitLab

View all 5 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5b7eaa7 | Docs | View more details | Give us feedback!

@vlad-scherbich
vlad-scherbich force-pushed the vlad/py315-current-py-version branch from 3f0ff70 to c8b4968 Compare August 28, 2026 18:36
@vlad-scherbich vlad-scherbich changed the title chore(compat): add CURRENT_PY_VERSION and bump NEXT_PY_VERSION to 3.16 chore(compat): add CURRENT_PY_VERSION and bump NEXT_PY_VERSION to 3.16 (PROF-14439) Aug 28, 2026
@vlad-scherbich vlad-scherbich changed the title chore(compat): add CURRENT_PY_VERSION and bump NEXT_PY_VERSION to 3.16 (PROF-14439) chore(compat): add MAX_PY_VERSION (3.15) and NEXT_MAX_PY_VERSION (3.16) (PROF-14439) Aug 28, 2026
@vlad-scherbich vlad-scherbich changed the title chore(compat): add MAX_PY_VERSION (3.15) and NEXT_MAX_PY_VERSION (3.16) (PROF-14439) chore(compat): MAX/NEXT_MAX bounds and PY_GTE_* support predicates (PROF-14439) Aug 28, 2026
@vlad-scherbich
vlad-scherbich requested a lite review from Copilot August 28, 2026 20:37
@vlad-scherbich vlad-scherbich changed the title chore(compat): MAX/NEXT_MAX bounds and PY_GTE_* support predicates (PROF-14439) chore(compat): universal MAX/NEXT_MAX py version bounds (PROF-14439) Aug 28, 2026

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

Pull request overview

This PR standardizes Python version bound constants in ddtrace.internal.compat by introducing MAX_PY_VERSION / NEXT_MAX_PY_VERSION and derived predicates (PY_GTE_MAX, PY_GTE_NEXT_MAX), then updates internal call sites and tests to use these shared checks (including wrapping fail-closed behavior and injection runtime allow-listing).

Changes:

  • Add MAX/NEXT_MAX version constants + predicates to ddtrace.internal.compat.
  • Replace ad-hoc version comparisons with shared predicates in wrapping-related code paths and tests.
  • Align injection bootstrap runtime allow-list upper bound with NEXT_MAX_PY_VERSION_INFO.

Reviewed changes

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

Show a summary per file
File Description
ddtrace/internal/compat.py Adds MAX/NEXT_MAX constants and PY_GTE_* predicates (with updated exports).
ddtrace/internal/wrapping/__init__.py Switches wrap/wrap_bytecode fail-closed gate to PY_GTE_MAX.
ddtrace/internal/wrapping/context.py Switches the 3.16+ fail-closed import-time gate to PY_GTE_NEXT_MAX.
ddtrace/internal/module.py Updates lazy-module behavior gating to PY_GTE_MAX.
ddtrace/internal/monitoring.py Replaces 3.15+ import guard with a MAX-based guard/message.
ddtrace/internal/coverage/instrumentation_py3_12.py Replaces hardcoded 3.15 boundaries with MAX_PY_VERSION_INFO for PEP 810-related behavior.
lib-injection/sources/sitecustomize.py Sets injection runtime exclusive upper bound to (3, 16) via NEXT_MAX_PY_VERSION_INFO.
tests/internal/test_py315_import_degrade.py Adds assertions for the new constants/predicates and updates skipifs to use PY_GTE_MAX.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ddtrace/internal/compat.py Outdated
Comment thread ddtrace/internal/monitoring.py Outdated
@vlad-scherbich vlad-scherbich changed the title chore(compat): universal MAX/NEXT_MAX py version bounds (PROF-14439) chore(compat): MAX=3.14 last-supported, NEXT_MAX=3.15 fail-closed (PROF-14439) Aug 29, 2026
@vlad-scherbich vlad-scherbich changed the title chore(compat): MAX=3.14 last-supported, NEXT_MAX=3.15 fail-closed (PROF-14439) chore(compat): MAX_PY=3.14 last-supported, NEXT_MAX_PY=3.15 fail-closed (PROF-14439) Aug 29, 2026
@vlad-scherbich
vlad-scherbich force-pushed the vlad/py315-current-py-version branch from ee96ec3 to cd21a98 Compare August 31, 2026 18:36
@vlad-scherbich
vlad-scherbich force-pushed the vlad/py315-current-py-version branch from 8d6df69 to f14152f Compare September 2, 2026 16:09
@vlad-scherbich vlad-scherbich changed the title chore(compat): MAX_PY=3.14 last-supported, NEXT_MAX_PY=3.15 fail-closed (PROF-14439) chore(compat): MAX_PY=3.14 last-supported, wrap fail-closes at 3.16 (PROF-14439) Sep 2, 2026
@vlad-scherbich
vlad-scherbich force-pushed the vlad/py315-current-py-version branch from f14152f to 38e7bef Compare September 2, 2026 19:10
…imited-API

PyContextVar_New/_Get/_Set are absent from pyo3-ffi limited-API bindings.
PyGILState_Check is not limited-API; on those builds skip the probe rather
than acquire or guess from a crash signal handler.
rust-ci runs clippy -D warnings; rustdoc does not document extern blocks,
so the /// notes were unused_doc_comments.
Wheel smoke tests fail on 3.15 because wrapping raises at import and
profiling.auto loads native extensions that are not built yet. Defer
the wrapping error until wrap is actually used, and disable the
profiler when those extensions are missing.
Address Copilot review on PR #19267: eject_all_hooks is intentionally a
no-op compatibility stub (injection disabled on NEXT_PY_VERSION_INFO+),
and _first_instr_line docstring uses plain text consistent with the module.
Restore blank line after local import removed during rebase conflict resolution.
starts_line became a bool in 3.13, not 3.15, so main's existing 3.14+
branch already covers 3.15. The unified helper also changed targeting
on 3.11-3.13 by skipping co_firstlineno. Restore the version-split
implementation and use plain-text comments in logging/patch.py.
Iterate snapshot wrapping contexts by value so restore_all has no unused name.
Keep the list() snapshots; the named annotated temps were not part of the 3.15 delta.
logging.__version__ is deprecated on 3.15+ with no replacement API.
Match stdlib integrations (unittest, subprocess, urllib) instead of
silencing the warning.
List 3.15 in SUPPORTED_PYTHON_VERSIONS so select_pys can opt in.
Default MAX stays 3.14. Smoke and sourcecode opt in.
check_requirements_lockfiles prunes hashes riot list does not emit.
Keep smoke_test (b388a93) and sourcecode (c2ce19f) only.
Rename support bounds to MAX_PY / NEXT_MAX_PY. Pin PY_315_VERSION_INFO for
3.15-only APIs. wrap() and lazy stay live on 3.15 and fail closed from 3.16,
not NEXT_MAX_PY. requires-python stays <3.15.
@vlad-scherbich
vlad-scherbich force-pushed the vlad/py315-current-py-version branch from 38e7bef to 5b7eaa7 Compare September 2, 2026 20:14
@vlad-scherbich
vlad-scherbich changed the base branch from vlad/py315-riotfile to main September 3, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants