Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7899267
phase2 mvp: add HTTPXWrapper behind use_httpx flag
mwdd146980 May 22, 2026
72d4bc3
phase2 mvp: add changelog fragment
mwdd146980 May 22, 2026
108567d
phase2 mvp: address agint:review iteration 1
mwdd146980 May 22, 2026
5b5b029
phase2 mvp: address agint:review iteration 2
mwdd146980 May 22, 2026
3962a15
phase2 mvp: condense docstrings to teammate style
mwdd146980 May 26, 2026
0d65e5a
phase2 mvp: rephrase kong/kuma httpx opt-in comments
mwdd146980 May 26, 2026
5dc8326
phase2 mvp: align httpx tests with teammate norms
mwdd146980 May 26, 2026
ade5123
phase2 mvp: drop encoding-setter test (httpx passthrough)
mwdd146980 May 26, 2026
f59e1b7
scope MVP to design validation: revert kong/kuma + mock_http_response…
mwdd146980 May 28, 2026
424f0bf
consolidate changelog into 22676.added for feature branch merge
mwdd146980 May 28, 2026
5d56e6d
phase2 mvp: close httpx.Client explicitly in dispatch test
mwdd146980 May 28, 2026
313b9de
phase2 mvp: tighten httpx wrapper kwargs + base_scraper raise
mwdd146980 May 28, 2026
ac4a518
phase2 mvp: stream httpx wrapper body via client.send(stream=True)
mwdd146980 May 28, 2026
d92d80b
phase2 mvp: address review iteration 2 test feedback
mwdd146980 May 28, 2026
8e8c4a5
phase2 mvp: drop unreachable reason fallback
mwdd146980 May 29, 2026
b6ec5ae
phase2 mvp: drop allow_redirects per-request kwarg + comment proxies …
mwdd146980 May 29, 2026
66f2302
phase2 mvp: route httpx.InvalidURL through HTTPInvalidURLError
mwdd146980 May 29, 2026
fd2e807
phase2 mvp: align HTTPXResponseAdapter with HTTPResponseProtocol shape
mwdd146980 May 29, 2026
5f97af4
phase2 mvp: parametrize auth/dispatch tests, cover default-wrapper path
mwdd146980 May 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datadog_checks_base/changelog.d/22676.added
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Add library-agnostic HTTP mocks/proto/exceptions and migrate intg tests.
Add library-agnostic HTTP mocks/proto/exceptions and migrate intg tests. Add ``HTTPXWrapper``, an httpx-backed HTTP client opt-in via the ``use_httpx`` instance config flag. The default remains the existing requests-based client.
12 changes: 9 additions & 3 deletions datadog_checks_base/datadog_checks/base/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,16 @@ def http(self) -> HTTPClientProtocol:
Only new checks or checks on Agent 6.13+ can and should use this for HTTP requests.
"""
if not hasattr(self, '_http'):
# See Performance Optimizations in this package's README.md.
from datadog_checks.base.utils.http import RequestsWrapper
instance = self.instance or {}
if is_affirmative(instance.get('use_httpx', False)):
from datadog_checks.base.utils.http_httpx import HTTPXWrapper

self._http = HTTPXWrapper(instance, self.init_config, self.HTTP_CONFIG_REMAPPER, self.log)
else:
# See Performance Optimizations in this package's README.md.
from datadog_checks.base.utils.http import RequestsWrapper

self._http = RequestsWrapper(self.instance or {}, self.init_config, self.HTTP_CONFIG_REMAPPER, self.log)
self._http = RequestsWrapper(instance, self.init_config, self.HTTP_CONFIG_REMAPPER, self.log)

return self._http

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from datadog_checks.base.constants import ServiceCheck
from datadog_checks.base.errors import ConfigurationError
from datadog_checks.base.utils.functions import no_op, return_true
from datadog_checks.base.utils.http_exceptions import HTTPConnectionError


class OpenMetricsScraper:
Expand Down Expand Up @@ -405,11 +406,11 @@ def stream_connection_lines(self):
self._content_type = connection.headers.get('Content-Type', '')
for line in connection.iter_lines(decode_unicode=True):
yield line
except ConnectionError as e:
except (ConnectionError, HTTPConnectionError) as e:
if self.ignore_connection_errors:
self.log.warning("OpenMetrics endpoint %s is not accessible", self.endpoint)
self.log.warning("OpenMetrics endpoint %s is not accessible: %s", self.endpoint, e)
else:
raise e
raise

def filter_connection_lines(self, line_streamer):
"""
Expand Down
Loading
Loading