Skip to content

Add HTTPX2Wrapper MVP#23883

Merged
mwdd146980 merged 51 commits into
mwdd146980/httpx-migration-basefrom
mwdd146980/phase2-httpx2-wrapper-mvp
Jun 24, 2026
Merged

Add HTTPX2Wrapper MVP#23883
mwdd146980 merged 51 commits into
mwdd146980/httpx-migration-basefrom
mwdd146980/phase2-httpx2-wrapper-mvp

Conversation

@mwdd146980

@mwdd146980 mwdd146980 commented May 29, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds an HTTPX2Wrapper backed by httpx2 behind a use_httpx2 instance config flag. The default remains RequestsWrapper. Also widens the OpenMetrics v2 scraper to catch HTTPConnectionError alongside requests.exceptions.ConnectionError.

Motivation/Why

Design validation for the migration RFC. httpx2 is the Pydantic-maintained successor to httpx. The goal is to land on a maintained library before any integration opts in.

Approach

  • New HTTPX2Wrapper sits alongside RequestsWrapper in datadog_checks/base/utils/.
  • AgentCheck.http dispatches to HTTPX2Wrapper only when the instance sets use_httpx2: true. Otherwise it constructs RequestsWrapper exactly as before, so the default path is untouched.
  • The wrapper exposes a library-agnostic response adapter and maps httpx2 exceptions onto the shared http_exceptions hierarchy. This translation runs only on the new engine's side: RequestsWrapper still raises native requests exceptions, so callers cannot yet rely on a single neutral contract regardless of backend. The OM v2 scraper works across both clients because it was explicitly taught to catch the requests and httpx2 connection errors side by side. Full exception-contract unification across both backends is follow-up work, not part of this PR.
  • The shared HTTPResponseProtocol is widened with encoding (read + setter), url, cookies, and elapsed, plus @runtime_checkable, so both wrappers' response adapters expose the same surface. Existing callers that wrote through response.encoding are now protocol-covered.
  • The OM v2 scraper's connection-error handler is widened to (ConnectionError, HTTPConnectionError) so a streamed scrape fails the same way under either client.

Verification

  • New unit suite under tests/base/utils/httpx2/ covers verb dispatch, config/TLS/auth propagation, exception mapping, lifecycle/dispatch, the response adapter, and the OM scraper connection-error paths.
  • ddev test -fs datadog_checks_base passes (format + style clean).
  • Full datadog_checks_base base suite green except pre-existing kerberos/socks5 integration tests that require Docker (unrelated to this change).
  • Default RequestsWrapper behavior is unchanged: no integration sets use_httpx2, so production callers are unaffected.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented May 29, 2026

Copy link
Copy Markdown

Pipelines  Tests  Code Coverage

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

Validate repository | Run Validations / Validate   View in Datadog   GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 97.65%
Overall Coverage: 88.15% (+0.05%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9e932e7 | Docs | Datadog PR Page | Give us feedback!

@mwdd146980 mwdd146980 mentioned this pull request May 29, 2026
3 tasks
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.64585% with 23 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (mwdd146980/httpx-migration-base@f14a5ce). Learn more about missing BASE report.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mwdd146980 mwdd146980 self-assigned this Jun 2, 2026
@mwdd146980 mwdd146980 added the qa/skip-qa Automatically skip this PR for the next QA label Jun 2, 2026
mwdd146980 added a commit that referenced this pull request Jun 3, 2026
mwdd146980 added a commit that referenced this pull request Jun 3, 2026
mwdd146980 added a commit that referenced this pull request Jun 3, 2026
mwdd146980 added a commit that referenced this pull request Jun 3, 2026
mwdd146980 added a commit that referenced this pull request Jun 3, 2026
mwdd146980 added a commit that referenced this pull request Jun 3, 2026
mwdd146980 added a commit that referenced this pull request Jun 3, 2026
mwdd146980 added a commit that referenced this pull request Jun 3, 2026
mwdd146980 added a commit that referenced this pull request Jun 3, 2026
@mwdd146980
mwdd146980 force-pushed the mwdd146980/phase2-httpx2-wrapper-mvp branch from 8a7b8bf to 559bd70 Compare June 4, 2026 17:23
@mwdd146980

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 5f33a4ef93

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread datadog_checks_base/datadog_checks/base/utils/httpx2.py
@mwdd146980

Copy link
Copy Markdown
Contributor Author

@codex review

@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: ce35d7bb7f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread datadog_checks_base/datadog_checks/base/utils/httpx2.py
@mwdd146980 mwdd146980 changed the title Add HTTPXWrapper backed by httpx2 Add HTTPX2Wrapper backed by httpx2 Jun 9, 2026
@mwdd146980 mwdd146980 changed the title Add HTTPX2Wrapper backed by httpx2 Add HTTPX2Wrapper MVP Jun 9, 2026
mwdd146980 and others added 4 commits June 17, 2026 16:49
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Validation Report

Validation Description Status
dep Verify dependency pins are consistent and Agent-compatible

Run ddev validate all changed --fix to attempt to auto-fix supported validations.

Passed validations (20)
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@mwdd146980
mwdd146980 merged commit e37930e into mwdd146980/httpx-migration-base Jun 24, 2026
345 of 349 checks passed
@mwdd146980
mwdd146980 deleted the mwdd146980/phase2-httpx2-wrapper-mvp branch June 24, 2026 22:22
mwdd146980 added a commit that referenced this pull request Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants