Skip to content

chore(compat): MAX_PY=3.14 last-supported, NEXT_MAX_PY=3.15 fail-closed (PROF-14439) - #19928

Draft
vlad-scherbich wants to merge 20 commits into
vlad/py315-riotfilefrom
vlad/py315-current-py-version
Draft

chore(compat): MAX_PY=3.14 last-supported, NEXT_MAX_PY=3.15 fail-closed (PROF-14439)#19928
vlad-scherbich wants to merge 20 commits into
vlad/py315-riotfilefrom
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; matches requires-python <3.15). NEXT_MAX_PY is derived from MAX_PY as (3, 15). wrap/lazy do not raise at NEXT_MAX_PY; they match merged #19910 (trampoline / WrappingContext on 3.15) and fail-close at 3.16. PY_315_VERSION_INFO is the CPython API floor and is never aliased to MAX_PY. After 3.15 GAs, bump MAX_PY to (3, 15).

WrappingContext raises at 3.16 (monitoring already works on 3.15). SSI exclusive max is 3.16 so 3.15 injection remains (#19843).

Layer Meaning Which PR
Compiled into artifact n/a
Armed at runtime wrap() live on 3.15; fail-close at 3.16 this PR (ports #19910)
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) and not aliased to MAX_PY. wrap() runs on 3.15; monkeypatch pins fail-close at 3.16.

Risks

None.

Additional Notes

Does not change requires-python. SSI/WrappingContext use 3.16, not NEXT_MAX_PY.

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 240 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 240 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=135)
ddtrace.internal.ci_visibility.filters -×-> ddtrace.trace  (product:ci_visibility -> product:tracing, score=133)
ddtrace.internal.ci_visibility.api._base -×-> ddtrace.trace  (product:ci_visibility -> product:tracing, score=133)
ddtrace.appsec._listeners -×-> ddtrace.trace  (product:appsec -> product:tracing, score=133)
ddtrace.llmobs._utils -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=133)

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.

.gitlab/scripts/prune-unsupported-wheels.sh                             @DataDog/python-guild @DataDog/apm-core-python
.gitlab/templates/cached-testrunner.yml                                 @DataDog/python-guild @DataDog/apm-core-python
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/module.py                                              @DataDog/debugger-python @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
hooks/pre-commit/05-run-bandit                                          @DataDog/python-guild
hooks/scripts/run-mypy.sh                                               @DataDog/python-guild
lib-injection/sources/sitecustomize.py                                  @DataDog/apm-core-python
pyproject.toml                                                          @DataDog/python-guild
riotfile.py                                                             @DataDog/apm-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-08-30 03:22:39

Comparing candidate commit 57ccbdc in PR branch vlad/py315-current-py-version with baseline commit 23f857d in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 7 performance regressions! Performance is the same for 578 metrics, 10 unstable metrics, 3 known flaky benchmarks, 15 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.458µs; +2.661µs] or [+7.724%; +8.363%]

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+2.786µs; +2.921µs] or [+16.994%; +17.815%]

scenario:iastaspects-add_aspect

  • 🟥 execution_time [+7.700µs; +9.437µs] or [+7.587%; +9.299%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+126.853µs; +133.764µs] or [+30.225%; +31.871%]

scenario:iastaspectssplit-rsplit_aspect

  • 🟥 execution_time [+38.158µs; +44.043µs] or [+26.217%; +30.261%]

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

  • 🟥 execution_time [+620.966ns; +669.694ns] or [+22.947%; +24.748%]

scenario:tracer-small

  • 🟥 execution_time [+31.037µs; +33.986µs] or [+9.363%; +10.252%]

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 [-745.334ns; +730.727ns] or [-6.773%; +6.641%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-29.726ns; +36.987ns] or [-4.887%; +6.081%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1650.691ns; +1638.711ns] or [-9.694%; +9.624%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1344.411ns; +1194.616ns] or [-10.157%; +9.025%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-324.512ns; +327.334ns] or [-8.811%; +8.888%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-252.655ns; +260.493ns] or [-8.611%; +8.879%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-72.384ns; +72.312ns] or [-6.163%; +6.157%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3798.634ns; +4126.741ns] or [-9.330%; +10.135%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-848.792ns; +703.721ns] or [-10.411%; +8.632%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-57.460µs; +60.233µs] or [-9.221%; +9.666%]

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-casefold_noaspect

  • 🟥 execution_time [+64.462µs; +70.032µs] or [+26.238%; +28.505%]

scenario:iastaspects-translate_aspect

  • 🟥 execution_time [+91.762µs; +102.161µs] or [+21.214%; +23.618%]

scenario:span-start

  • 🟥 execution_time [+1.121ms; +1.303ms] or [+7.861%; +9.137%]

Known flaky benchmarks without significant changes:

  • scenario:errortrackingflasksqli-baseline
  • scenario:flasksimple-iast-get
  • scenario:iastaspects-casefold_aspect
  • scenario:iastaspects-index_aspect
  • scenario:iastaspects-ljust_noaspect
  • scenario:iastaspects-lower_aspect
  • scenario:iastaspects-replace_aspect
  • scenario:iastaspects-swapcase_aspect
  • scenario:iastaspects-title_noaspect
  • 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

Unblock PR with BitsAI

⚠️ Warnings

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

🚦 6 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | check_requirements_lockfiles — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | prechecks — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | rust ci — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

View all 6 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: 57ccbdc | Docs | View more details | Give us feedback!

Centralize the 3.15 wiring bound and the 3.16 fail-closed bound so wrap()
can keep raising on 3.15 while NEXT_PY means first unsupported.
@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
inject_hook is monitoring-based on 3.15 and no longer raises.
…XT_MAX

We support a range of CPythons; MAX is the upper bound we code against and NEXT_MAX is the first past that.
@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
Fail-closed wrap/lazy sites use PY_GTE_MAX (one TODO to flip to NEXT_MAX after 3.15 GAs). SSI and WrappingContext use NEXT_MAX.
@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
MAX is a support bound; a later bump must not retie CPython API floors.
Compare to MAX/NEXT_MAX_INFO at call sites so __all__ is not a second pile of version names.
mypy only narrows sys.version_info against literals, so named aliases left
sys.monitoring reachable under python_version 3.10.
@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
#19861 only makes cp315 optional in the package validator. Un-prune after
IMAGE_TAG can build a correct wheel, and only once 3.15 is supported.

(cherry picked from commit 703428b)
Monitoring inject_hook already works. The wrap raise tests are skipif
below NEXT and would demand a raise after wrap lift; they do not pin
this PR error-string change.

(cherry picked from commit 08c8693)
The SSI max bump does not need a bandit/mypy skip of lib-injection/.

(cherry picked from commit 0cf5c73)
Lint extra bytecode==0.18.1 on 3.15 is not the runtime dep
bytecode>=0.19.0. Leave both; they are different extras.

(cherry picked from commit 5bd7d37)
Drop it once the testrunner 3.15 interpreter is 3.15.0rc1+, when Cython 3.3 cp315 wheels no longer SIGSEGV.

(cherry picked from commit fbea5a1)
#17849 wrapping is merging to main; hashes sharing jobs and pip
install -e . (#19904) are the remaining reasons MAX stays 3.14.

(cherry picked from commit 117a724)
httplib, dbapi, subprocess, and detect_global_locks wrap and share
GitLab --exitfirst jobs. wrap() still raises on 3.15 on this stack.

(cherry picked from commit 79d6534)
NEXT_MAX_PY is 3.15 (packaging). wrap() and lazy must match merged
#19910: trampoline and WrappingContext are live on 3.15, fail closed
from 3.16. A rebase onto main must not re-disable wrap on 3.15.
Lint extra bytecode==0.18.1 conflicts with runtime bytecode>=0.19.0
when uv resolves extras for requires-python that includes 3.15.

(cherry picked from commit cac61ca)
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