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) 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