From 700776d4b9c5b93be5e5974c88495a7ec70201c1 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 21 Nov 2024 17:24:21 +0100 Subject: [PATCH 1/2] opentelemetry-instrumentation-httpx: drop unused private classes Unused since f6b68d0c024cf40d15c08062a18bf70ea73847e6 --- .../instrumentation/httpx/__init__.py | 71 ------------------- 1 file changed, 71 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py b/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py index 92e044bf06..195c784408 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py @@ -641,77 +641,6 @@ async def aclose(self) -> None: await self._transport.aclose() -class _InstrumentedClient(httpx.Client): - _tracer_provider = None - _request_hook = None - _response_hook = None - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - self._original_transport = self._transport - self._original_mounts = self._mounts.copy() - self._is_instrumented_by_opentelemetry = True - - self._transport = SyncOpenTelemetryTransport( - self._transport, - tracer_provider=_InstrumentedClient._tracer_provider, - request_hook=_InstrumentedClient._request_hook, - response_hook=_InstrumentedClient._response_hook, - ) - self._mounts.update( - { - url_pattern: ( - SyncOpenTelemetryTransport( - transport, - tracer_provider=_InstrumentedClient._tracer_provider, - request_hook=_InstrumentedClient._request_hook, - response_hook=_InstrumentedClient._response_hook, - ) - if transport is not None - else transport - ) - for url_pattern, transport in self._original_mounts.items() - } - ) - - -class _InstrumentedAsyncClient(httpx.AsyncClient): - _tracer_provider = None - _request_hook = None - _response_hook = None - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - self._original_transport = self._transport - self._original_mounts = self._mounts.copy() - self._is_instrumented_by_opentelemetry = True - - self._transport = AsyncOpenTelemetryTransport( - self._transport, - tracer_provider=_InstrumentedAsyncClient._tracer_provider, - request_hook=_InstrumentedAsyncClient._request_hook, - response_hook=_InstrumentedAsyncClient._response_hook, - ) - - self._mounts.update( - { - url_pattern: ( - AsyncOpenTelemetryTransport( - transport, - tracer_provider=_InstrumentedAsyncClient._tracer_provider, - request_hook=_InstrumentedAsyncClient._request_hook, - response_hook=_InstrumentedAsyncClient._response_hook, - ) - if transport is not None - else transport - ) - for url_pattern, transport in self._original_mounts.items() - } - ) - - class HTTPXClientInstrumentor(BaseInstrumentor): # pylint: disable=protected-access,attribute-defined-outside-init """An instrumentor for httpx Client and AsyncClient From d826da86e7070825f381c25bc5e1beda98d553a1 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 21 Nov 2024 17:28:40 +0100 Subject: [PATCH 2/2] Add CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1298977849..51ecc94d8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#2971](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2971)) - Drop `opentelemetry-instrumentation-test` package from default instrumentation list ([#2969](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2969)) +- `opentelemetry-instrumentation-httpx`: remove private unused `_InstrumentedClient` and `_InstrumentedAsyncClient` classes + ([#3036](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3036)) ## Version 1.28.0/0.49b0 (2024-11-05)