Skip to content

chore: extract shared appsec response adapter - #21620

Draft
quinna-h wants to merge 2 commits into
codex/flask-wsgi-shared-lifecyclefrom
codex/flask-shared-appsec-response-adapter
Draft

quinna-h wants to merge 2 commits into
codex/flask-wsgi-shared-lifecyclefrom
codex/flask-shared-appsec-response-adapter

Conversation

@quinna-h

@quinna-h quinna-h commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Extract Flask’s shared AppSec response adapter into an inactive module on top of #21617’s deferred Flask/WSGI lifecycle.

Include the shared inspection events and execution helper, with tests covering request- and response-time blocking, blocked response construction, discarded-response cleanup, exception propagation, and repeated-header preservation.

Future activation must reuse the existing request context and lifecycle owner.

Testing

34 Flask adapter and lifecycle tests passed.
2 Flask auto-patching smoke tests passed.
63 WSGI tests passed.

Risks

Additional Notes

@quinna-h quinna-h changed the title Codex/flask shared appsec response adapter shared appsec response adapter Nov 9, 2026
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against codex/flask-wsgi-shared-lifecycle using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

ddtrace/contrib/_events/web_framework.py                                @DataDog/python-guild @DataDog/apm-idm-python
ddtrace/contrib/internal/flask/response_adapter.py                      @DataDog/python-guild @DataDog/apm-idm-python
ddtrace/contrib/internal/web_framework.py                               @DataDog/python-guild @DataDog/apm-idm-python
ddtrace/internal/README.md                                              @DataDog/apm-core-python
tests/contrib/flask/test_request_adapter.py                             @DataDog/python-guild @DataDog/apm-idm-python

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

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

Show existing violations (showing 5 of 83 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=121)
ddtrace.llmobs._integrations.vllm -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=119)
ddtrace.llmobs._integrations.bedrock -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=119)
ddtrace.llmobs._integrations.vertexai -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=119)
ddtrace.llmobs._integrations.typesafe -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=119)

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

@quinna-h quinna-h added the changelog/no-changelog A changelog entry is not required for this PR. label Nov 9, 2026
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@quinna-h
quinna-h force-pushed the codex/flask-shared-appsec-response-adapter branch from 7467e0a to ad71a21 Compare November 9, 2026 21:21
@quinna-h quinna-h changed the title shared appsec response adapter chore: extract shared appsec response adapter Nov 9, 2026
@pr-commenter

pr-commenter Bot commented Nov 9, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-09 21:47:54

Comparing candidate commit ad71a21 in PR branch codex/flask-shared-appsec-response-adapter with baseline commit a5adee6 in branch codex/flask-wsgi-shared-lifecycle.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 576 metrics, 9 unstable metrics, 1 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 ----------------------------------'

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 [-741.699ns; +665.150ns] or [-6.866%; +6.157%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1845.099ns; +1861.270ns] or [-9.191%; +9.271%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1754.453ns; +1778.042ns] or [-9.060%; +9.182%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-393.654ns; +328.015ns] or [-8.997%; +7.497%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-197.303ns; +238.194ns] or [-7.288%; +8.798%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-84.433ns; +91.644ns] or [-5.711%; +6.199%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-4419.919ns; +5183.619ns] or [-8.672%; +10.171%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-1066.473ns; +846.495ns] or [-9.803%; +7.781%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-52.144µs; +58.076µs] or [-8.953%; +9.971%]

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.

Known flaky benchmarks without significant changes:

  • scenario:packagespackageforrootmodulemapping-cache_off

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.

1 participant