chore(iast): type logging wrappers #22178
Codeowners resolved as
Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.
ddtrace/appsec/_iast/_aiohttp.py @DataDog/asm-python
ddtrace/appsec/_iast/_langchain.py @DataDog/asm-python
ddtrace/appsec/_iast/_logs.py @DataDog/asm-python
ddtrace/appsec/_iast/taint_sinks/code_injection.py @DataDog/asm-python
ddtrace/appsec/_iast/taint_sinks/command_injection.py @DataDog/asm-python
ddtrace/appsec/_iast/taint_sinks/header_injection.py @DataDog/asm-python
ddtrace/appsec/_iast/taint_sinks/path_traversal.py @DataDog/asm-python
ddtrace/appsec/_iast/taint_sinks/sql_injection.py @DataDog/asm-python
ddtrace/appsec/_iast/taint_sinks/untrusted_serialization.py @DataDog/asm-python
ddtrace/appsec/_iast/taint_sinks/weak_cipher.py @DataDog/asm-python
ddtrace/appsec/_iast/taint_sinks/weak_hash.py @DataDog/asm-python
mypy.ini @DataDog/apm-python-guild @DataDog/apm-core-python
scripts/check_constant_log_message.py @DataDog/apm-python-guild
Dependency direction analysis
⚠️ Existing dependency direction violations
There are 22 dependency direction violations that already exist on the base branch and have not been changed by this PR.
<details><summary>Show existing violations (showing 5 of 22 highest severity)</summary>
ddtrace.internal.tracemethods -×-> ddtrace.trace (internal-core -> product:tracing, score=103)
ddtrace.llmobs._integrations.base -×-> ddtrace.trace (product:llmobs -> product:tracing, score=101)
ddtrace.llmobs._integrations.bedrock_agents -×-> ddtrace.trace (product:llmobs -> product:tracing, score=101)
ddtrace.internal.span_bus -×-> ddtrace._trace.span (internal-core -> product:tracing, score=35)
ddtrace.llmobs._llmobs -×-> ddtrace._trace.span (product:llmobs -> product:tracing, score=33)
</details>
To see all violations, download thelayers-base.jsonandlayers-pr.jsonartifacts from this CI job and run:
> uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json >
Benchmarks
Benchmark execution time: 2026-11-30 10:48:42
Comparing candidate commit 33793ac3ccb80e6c2bd4ec736c88334af01fbe66 in PR branch dd/asm/hypertyper-iast-logging-20261130 with baseline commit 498511e8e1f87b07f4925fa85abb7cb85619e171 in branch main.
Found 0 performance improvements and 0 performance regressions! Performance is the same for 562 metrics, 10 unstable metrics, 1 flaky benchmarks without significant changes.
<details>
<summary><h3>Explanation</h3></summary>
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.
<details>
<summary><h4>More details about the CI and significant changes</h4></summary>
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 ----------------------------------'
</details>
</details>
<details>
<summary><h3>Unstable benchmarks</h3></summary>
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
execution_time [-633.329ns; +815.150ns] or [-5.968%; +7.681%]scenario:coreapiscenario-core_dispatch_1_listener
execution_time [-37.293ns; +40.554ns] or [-5.863%; +6.376%]scenario:coreapiscenario-core_dispatch_50_listeners
execution_time [-1722.495ns; +2106.650ns] or [-8.705%; +10.647%]scenario:coreapiscenario-core_dispatch_exception_listeners
execution_time [-2223.360ns; +1477.861ns] or [-11.307%; +7.516%]scenario:coreapiscenario-core_dispatch_listeners
execution_time [-351.536ns; +406.091ns] or [-8.330%; +9.622%]scenario:coreapiscenario-core_dispatch_no_args_listeners
execution_time [-206.480ns; +246.881ns] or [-7.827%; +9.358%]scenario:coreapiscenario-core_dispatch_with_results_1_listener
execution_time [-95.345ns; +85.069ns] or [-6.912%; +6.167%]scenario:coreapiscenario-core_dispatch_with_results_50_listeners
execution_time [-5224.342ns; +4110.285ns] or [-10.631%; +8.364%]scenario:coreapiscenario-core_dispatch_with_results_listeners
execution_time [-1157.261ns; +734.088ns] or [-11.037%; +7.001%]scenario:packagesupdateimporteddependencies-import_many_stdlib_cached
execution_time [-48.752µs; +60.079µs] or [-8.440%; +10.401%]</details>
<details>
<summary><h3>Known flaky benchmarks</h3></summary>
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:
</details>
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"33793ac3ccb80e6c2bd4ec736c88334af01fbe66","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":"33793ac3ccb80e6c2bd4ec736c88334af01fbe66","has_any_findings":null,"has_unresolved_findings":null,"status":"completed"}} -->
<!-- codex-security-review:v1 {"blockingSeverityThreshold":"P0","headSha":"33793ac3ccb80e6c2bd4ec736c88334af01fbe66","mergeGateEnabled":false,"pullRequestNumber":22178,"repository":"DataDog/dd-trace-py","status":"completed"} -->
<details>
<summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-30T10:27:35.265554Z">2026-11-30T10:27:35.265554Z</relative-time> | 33793ac | Draft marked ready |
| 🔒 Security Review | ✅ Completed <relative-time datetime="2026-11-30T10:33:03.180471Z">2026-11-30T10:33:03.180471Z</relative-time> | 33793ac | Draft marked ready |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
</details>
Approved these changes.
Approved these changes.
<details>
<summary>More details</summary>
The corrected calls forward exceptions through exc while preserving the intended IAST message prefixes. The completed static review identified no reportable defects; human PR discussion raised no additional concerns.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 33793ac</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=a1f27beb-5600-4118-b8db-302a8e62a5cc -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:3d5517522f576c9c5458979c43d8a99bbb959a68f822e32f818921dc5e5a83b8:bundle -->
christophe-papazian
florentinl
<!-- dd-meta {"pullId":"8d486c82-c04a-4fd4-981f-85a6269d4eae","source":"chat","resourceId":"7444233a-2820-48cb-99ab-d6e11d7ce1d1","workflowId":"268d4d07-1acb-4469-a83e-d34cbe3387a5","codeChangeId":"268d4d07-1acb-4469-a83e-d34cbe3387a5","sourceType":"action_platform_workflows"} -->
Description
Workflow Automation • View in Workflow Automation
Optional/Union,TypedDict+UnpackunderTYPE_CHECKING) to all logging wrapper functions inddtrace/appsec/_iast/_logs.py.[mypy-ddtrace.appsec._iast._logs]exemption frommypy.ini, delete four now-obsolete# type: ignore[no-untyped-call]comments inddtrace/appsec/_iast/_aiohttp.py, and update the line exception inscripts/check_constant_log_message.py(_logs.py:41->_logs.py:60).iast_error(default_prefix: str = "iast::", ...)and fix all 19 call sites across 9 files (_langchain.py,code_injection.py,command_injection.py,header_injection.py,path_traversal.py,sql_injection.py,untrusted_serialization.py,weak_cipher.py,weak_hash.py) that were passingepositionally asdefault_prefixinstead ofexc=e.Customer impact
None under default settings —
_set_iast_error_metriconly emits telemetry logs when IAST debug mode is enabled.Testing
Validated with
scripts/lint typing,scripts/lint checks(includingcheck_constant_log_message.py),scripts/lint type-comments-check --base-ref origin/main, and Python 3.9 IAST unit tests (tests/appsec/iast/test_telemetry.pyand affectedtests/appsec/iast/taint_sinks/suites: 228 passed, 42 skipped).Risks
Low — preserves all public/internal signatures while fixing the 19
iast_error(..., exc=e)error-reporting call sites.Additional Notes
None.
---
PR by Bits - View session in Datadog
Comment @datadog to request changes