Skip to content

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

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

chore(http_server): emit pre-request web event#19799
litianningdatadog wants to merge 2 commits into
tianning.li/2-web-request-starting-eventfrom
tianning.li/3-http-server-request-starting-event

Conversation

@litianningdatadog

@litianningdatadog litianningdatadog commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to #19779. 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 default-enabled like other auto-patched integrations 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.

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 #19779 and #19778.

@cit-pr-commenter-54b7da

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

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against tianning.li/2-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/_supported_configurations.py                  @DataDog/apm-python
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 20, 2026

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

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

Show existing violations (showing 5 of 254 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=134)
ddtrace.llmobs._integrations.litellm -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.debugging._signal.model -×-> ddtrace.trace  (product:debugging -> product:tracing, score=132)
ddtrace.llmobs._integrations.pydantic_ai -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.llmobs._integrations.claude_agent_sdk -×-> ddtrace.trace  (product:llmobs -> 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 20, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

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

ddtrace.contrib.internal.pytorch._distributed -> ddtrace.contrib.internal.pytorch._rank_root -> ddtrace.contrib.internal.pytorch._distributed
ddtrace.contrib.internal.django.patch -> ddtrace.contrib.internal.django.response -> ddtrace.contrib.internal.django.patch
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

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Aug 20, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 9 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 in Datadog · View in GitLab

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

View in Datadog · View in GitLab

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

View in Datadog · View in GitLab

View all 9 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: 5acedc0 | Docs | View more details | Give us feedback!

@litianningdatadog litianningdatadog added the changelog/no-changelog A changelog entry is not required for this PR. label Aug 20, 2026
@litianningdatadog litianningdatadog changed the title feat(http_server): emit pre-request web event chore(http_server): emit pre-request web event Aug 20, 2026
@litianningdatadog litianningdatadog added changelog/no-changelog A changelog entry is not required for this PR. and removed changelog/no-changelog A changelog entry is not required for this PR. labels Aug 20, 2026
@pr-commenter

pr-commenter Bot commented Aug 20, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-20 21:37:47

Comparing candidate commit 5acedc0 in PR branch tianning.li/3-http-server-request-starting-event with baseline commit c9ede47 in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 8 performance regressions! Performance is the same for 614 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.653µs; +2.823µs] or [+12.635%; +13.448%]

scenario:iast_aspects-re_sub_aspect

  • 🟥 execution_time [+28.027µs; +36.367µs] or [+7.170%; +9.304%]

scenario:iastaspects-title_noaspect

  • 🟥 execution_time [+13.915µs; +19.279µs] or [+7.315%; +10.134%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+122.384µs; +130.412µs] or [+30.596%; +32.602%]

scenario:iastaspectssplit-rsplit_aspect

  • 🟥 execution_time [+14.501µs; +20.171µs] or [+10.431%; +14.509%]

scenario:span-start

  • 🟥 execution_time [+1.358ms; +1.515ms] or [+9.212%; +10.277%]

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

  • 🟥 execution_time [+436.960ns; +468.786ns] or [+16.617%; +17.828%]

scenario:tracer-small

  • 🟥 execution_time [+29.502µs; +31.854µs] or [+8.706%; +9.401%]

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 [-691.484ns; +779.515ns] or [-6.358%; +7.167%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-30.988ns; +34.597ns] or [-5.106%; +5.701%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1699.302ns; +1592.145ns] or [-9.975%; +9.346%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1326.292ns; +1130.882ns] or [-10.264%; +8.752%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-331.755ns; +317.966ns] or [-9.030%; +8.654%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-256.861ns; +252.679ns] or [-8.784%; +8.641%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-82.005ns; +74.175ns] or [-7.005%; +6.336%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3633.400ns; +4450.148ns] or [-8.858%; +10.850%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-680.357ns; +912.561ns] or [-8.326%; +11.168%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-61.957µs; +58.412µs] or [-9.706%; +9.151%]

@litianningdatadog
litianningdatadog requested review from brettlangdon and dubloom and a balanced review from Copilot August 20, 2026 20:16

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

Adds default-enabled http.server instrumentation that emits the pre-request event without creating spans.

Changes:

  • Wraps successful BaseHTTPRequestHandler.parse_request calls.
  • Registers configuration, auto-patching, documentation, and test-suite metadata.
  • Adds patch lifecycle and event-dispatch coverage.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ddtrace/contrib/internal/http_server/patch.py Implements patching and event dispatch.
ddtrace/contrib/internal/http_server/__init__.py Documents the integration.
ddtrace/_monkey.py Enables automatic patching.
supported-configurations.json Registers the enable flag.
ddtrace/internal/settings/_supported_configurations.py Updates generated configuration data.
scripts/supported_configurations.py Supports integrations without service configuration.
scripts/integration_registry/registry.yaml Registers integration metadata.
docs/integrations.rst Adds documentation discovery.
riotfile.py Defines the test environment.
tests/contrib/suitespec.yml Adds suite-selection metadata.
tests/contrib/http_server/__init__.py Marks the test package.
tests/contrib/http_server/test_http_server_patch.py Tests patch lifecycle.
tests/contrib/http_server/test_microvm_identity_refresh.py Tests event dispatch behavior.
.riot/requirements/180047f.txt Adds Python 3.9 test dependencies.
.riot/requirements/3cb8c3c.txt Adds Python 3.10 test dependencies.
.riot/requirements/13ed954.txt Adds Python 3.11 test dependencies.
.riot/requirements/1362718.txt Adds Python 3.12 test dependencies.
.riot/requirements/43423a3.txt Adds Python 3.13 test dependencies.
.riot/requirements/1638d0f.txt Adds Python 3.14 test dependencies.

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



def _get_http_server() -> ModuleType:
# DEV: When patch() is called from the on-import hook, we're running from inside
@litianningdatadog litianningdatadog added the aws-microvm Work related to AWS MicroVM onboarding label Aug 21, 2026
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