Skip to content

chore(http_server): emit pre-request web event - #19817

Closed
litianningdatadog wants to merge 2 commits into
tianning.li/2-flask-web-request-starting-eventfrom
tianning.li/2-1-http-server-request-starting-event
Closed

litianningdatadog wants to merge 2 commits into
tianning.li/2-flask-web-request-starting-eventfrom
tianning.li/2-1-http-server-request-starting-event

Conversation

@litianningdatadog

@litianningdatadog litianningdatadog commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Stacked PRs:

Description

Follow-up to #19816. Adds a stdlib http_server integration for raw http.server handlers that need to emit WEB_REQUEST_STARTING before request handling continues.

The integration wraps http.server.BaseHTTPRequestHandler.parse_request and dispatches the event with (method, path) after the request line parses successfully. It does not create spans. It is automatically enabled only in AWS Lambda MicroVM environments, can be force-enabled with DD_TRACE_HTTP_SERVER_ENABLED=true, and can be disabled with DD_TRACE_HTTP_SERVER_ENABLED=false; it intentionally has no service-name config.

This PR also adds the integration metadata needed for auto-patching, docs discovery, suite selection, and supported-configuration validation. The .riot/requirements/*.txt files are generated locks for the new http_server Riot env across the Python versions selected by select_pys(). The supported-configuration checker now allows no-span integrations to skip DD_{NAME}_SERVICE[_NAME] entries.

This replaces #19799 after renaming the branch from tianning.li/3-http-server-request-starting-event to tianning.li/2-1-http-server-request-starting-event.

Testing

  • scripts/lint fmt ddtrace/_monkey.py ddtrace/contrib/internal/http_server/__init__.py ddtrace/contrib/internal/http_server/patch.py ddtrace/internal/settings/_supported_configurations.py riotfile.py scripts/supported_configurations.py tests/contrib/http_server/__init__.py tests/contrib/http_server/test_http_server_patch.py tests/contrib/http_server/test_microvm_identity_refresh.py
  • scripts/lint style ddtrace/_monkey.py ddtrace/contrib/internal/http_server/__init__.py ddtrace/contrib/internal/http_server/patch.py ddtrace/internal/settings/_supported_configurations.py riotfile.py scripts/supported_configurations.py tests/contrib/http_server/__init__.py tests/contrib/http_server/test_http_server_patch.py tests/contrib/http_server/test_microvm_identity_refresh.py
  • scripts/lint supported-config-check
  • scripts/run-tests --venv 13ed954 tests/contrib/http_server

Release note

No Reno fragment. This is internal runtime-identity plumbing for a no-span integration and does not change trace output by itself. Use changelog/no-changelog.

Additional Notes

Depends on #19816 and #19778.

@litianningdatadog litianningdatadog added changelog/no-changelog A changelog entry is not required for this PR. aws-microvm Work related to AWS MicroVM onboarding labels Aug 23, 2026
@litianningdatadog
litianningdatadog requested review from a team as code owners August 23, 2026 21:15
@litianningdatadog
litianningdatadog requested review from brettlangdon, dubloom and mabdinur and removed request for a team August 23, 2026 21:15
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines  Tests

✨ Unblock PR with BitsAI

⚠️ Warnings

🚦 5 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64, 1] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | build linux: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

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

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: a2cffdc | Docs | View more details | Give us feedback!

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55febfa654

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ddtrace/contrib/internal/http_server/patch.py Outdated
Comment thread ddtrace/contrib/internal/http_server/patch.py Outdated
Comment thread supported-configurations.json Outdated
Comment thread ddtrace/_monkey.py Outdated
Comment thread docs/integrations.rst
@litianningdatadog
litianningdatadog force-pushed the tianning.li/2-flask-web-request-starting-event branch from d59e112 to 16a5332 Compare August 24, 2026 02:23
@litianningdatadog
litianningdatadog force-pushed the tianning.li/2-1-http-server-request-starting-event branch from 55febfa to a32b7eb Compare August 24, 2026 02:24
@litianningdatadog
litianningdatadog force-pushed the tianning.li/2-flask-web-request-starting-event branch from 16a5332 to 8dd7e8e Compare August 24, 2026 02:31
@litianningdatadog
litianningdatadog force-pushed the tianning.li/2-1-http-server-request-starting-event branch from a32b7eb to 4b6f131 Compare August 24, 2026 02:31
@litianningdatadog
litianningdatadog force-pushed the tianning.li/2-flask-web-request-starting-event branch 4 times, most recently from 0fa6836 to cde3045 Compare August 24, 2026 17:19
@litianningdatadog
litianningdatadog force-pushed the tianning.li/2-1-http-server-request-starting-event branch from 4b6f131 to 99390d6 Compare August 24, 2026 18:22
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against tianning.li/2-flask-web-request-starting-event using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

.riot/requirements/1362718.txt                                          @DataDog/apm-python
.riot/requirements/13ed954.txt                                          @DataDog/apm-python
.riot/requirements/1638d0f.txt                                          @DataDog/apm-python
.riot/requirements/180047f.txt                                          @DataDog/apm-python
.riot/requirements/3cb8c3c.txt                                          @DataDog/apm-python
.riot/requirements/43423a3.txt                                          @DataDog/apm-python
ddtrace/_monkey.py                                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/http_server/__init__.py                        @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/http_server/patch.py                           @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/internal/settings/_config.py                                    @DataDog/python-guild @DataDog/apm-sdk-capabilities-python
ddtrace/internal/settings/_supported_configurations.py                  @DataDog/apm-python
docs/index.rst                                                          @DataDog/python-guild
docs/integrations.rst                                                   @DataDog/python-guild
riotfile.py                                                             @DataDog/apm-python
scripts/integration_registry/registry.yaml                              @DataDog/apm-idm-python
scripts/supported_configurations.py                                     @DataDog/apm-sdk-capabilities-python
supported-configurations.json                                           @DataDog/apm-python
tests/contrib/http_server/__init__.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/http_server/test_http_server_patch.py                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/http_server/test_microvm_identity_refresh.py              @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/suitespec.yml                                             @DataDog/python-guild
tests/tracer/test_monkey.py                                             @DataDog/apm-sdk-capabilities-python

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 24, 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 24, 2026 •

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

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

Show existing violations (showing 5 of 250 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=135)
ddtrace.internal.opentelemetry.trace -×-> ddtrace.trace  (product:opentelemetry -> product:tracing, score=133)
ddtrace.internal.opentelemetry.span -×-> ddtrace.trace  (product:opentelemetry -> product:tracing, score=133)
ddtrace.debugging._signal.model -×-> ddtrace.trace  (product:debugging -> product:tracing, score=133)
ddtrace.profiling.collector.stack -×-> ddtrace.trace  (product:profiling -> 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

@pr-commenter

pr-commenter Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-25 04:07:49

Comparing candidate commit a2cffdc in PR branch tianning.li/2-1-http-server-request-starting-event with baseline commit a0e3c42 in branch tianning.li/2-flask-web-request-starting-event.

📊 Benchmarking dashboard

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

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:httppropagationinject-ids_only

  • 🟥 execution_time [+2.018µs; +2.189µs] or [+10.518%; +11.409%]

scenario:iastaspects-add_aspect

  • 🟥 execution_time [+13.679µs; +17.989µs] or [+13.423%; +17.653%]

scenario:iastaspects-join_aspect

  • 🟥 execution_time [+46.397µs; +50.189µs] or [+22.018%; +23.817%]

scenario:iastaspects-ljust_noaspect

  • 🟥 execution_time [+58.326µs; +63.757µs] or [+20.531%; +22.443%]

scenario:iastaspects-title_aspect

  • 🟥 execution_time [+58.710µs; +67.462µs] or [+21.347%; +24.529%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+139.894µs; +147.478µs] or [+34.039%; +35.885%]

scenario:iastaspectssplit-rsplit_aspect

  • 🟥 execution_time [+16.841µs; +20.460µs] or [+11.712%; +14.228%]

scenario:span-start

  • 🟥 execution_time [+1.331ms; +1.495ms] or [+8.743%; +9.820%]

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

  • 🟥 execution_time [+406.923ns; +450.182ns] or [+14.864%; +16.444%]

scenario:tracer-small

  • 🟥 execution_time [+27.718µs; +30.273µs] or [+8.206%; +8.962%]

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 [-748.964ns; +732.356ns] or [-6.789%; +6.638%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-37.643ns; +28.503ns] or [-6.140%; +4.649%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1780.816ns; +1555.894ns] or [-10.350%; +9.043%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1248.967ns; +1218.121ns] or [-9.658%; +9.419%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-345.121ns; +312.996ns] or [-9.324%; +8.456%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-282.204ns; +226.823ns] or [-9.626%; +7.737%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-89.121ns; +57.630ns] or [-7.747%; +5.010%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3705.609ns; +4280.949ns] or [-9.206%; +10.636%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-738.106ns; +802.110ns] or [-9.259%; +10.062%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-60336.977ns; +60329.065ns] or [-9.439%; +9.438%]

@litianningdatadog
litianningdatadog force-pushed the tianning.li/2-1-http-server-request-starting-event branch 2 times, most recently from 26e1e27 to 667c969 Compare August 24, 2026 20:52
@litianningdatadog
litianningdatadog force-pushed the tianning.li/2-flask-web-request-starting-event branch from cde3045 to a0e3c42 Compare August 24, 2026 23:56
@litianningdatadog
litianningdatadog force-pushed the tianning.li/2-1-http-server-request-starting-event branch 3 times, most recently from 14e0ffb to 38761fa Compare August 25, 2026 03:17
@litianningdatadog
litianningdatadog marked this pull request as ready for review August 25, 2026 03:22

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38761fa550

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ddtrace/_monkey.py Outdated
"aiopg": True,
"aiobotocore": False,
"httplib": False,
"http_server": bool(env.get("AWS_LAMBDA_MICROVM_IMAGE_ARN")),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reuse the MicroVM predicate for the patch default

When AWS_LAMBDA_MICROVM_IMAGE_ARN contains only whitespace, in_aws_lambda_microvm() deliberately returns false after stripping the value, but this expression evaluates to true. In that environment _patch_all() therefore installs and reports the integration as automatically enabled even though its wrapper suppresses every event, adding an unnecessary check to every http.server request and contradicting the documented MicroVM-only default; derive this value using the same stripped predicate.

AGENTS.md reference: AGENTS.md:L16-L16

Useful? React with 👍 / 👎.

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

do we actually need this? are any customers asking for an http.server integration? is there any MicroVM setup that just uses http.server directly?

after about 10 years, this is the first I've seen it suggested as an integration.

@litianningdatadog

Copy link
Copy Markdown
Contributor Author

close it as it is out of the scope

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

Labels

aws-microvm Work related to AWS MicroVM onboarding 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