Skip to content

Commit 94295ac

Browse files
committed
check that sync hooks are callable
1 parent b15b83c commit 94295ac

File tree

1 file changed

+6
-2
lines changed
  • instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx

1 file changed

+6
-2
lines changed

instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,12 @@ def _instrument(self, **kwargs):
734734
``async_response_hook``: Async``response_hook`` for ``httpx.AsyncClient``
735735
"""
736736
tracer_provider = kwargs.get("tracer_provider")
737-
self._request_hook = kwargs.get("request_hook")
738-
self._response_hook = kwargs.get("response_hook")
737+
_request_hook = kwargs.get("request_hook")
738+
self._request_hook = _request_hook if callable(_request_hook) else None
739+
_response_hook = kwargs.get("response_hook")
740+
self._response_hook = (
741+
_response_hook if callable(_response_hook) else None
742+
)
739743
_async_request_hook = kwargs.get("async_request_hook")
740744
self._async_request_hook = (
741745
_async_request_hook

0 commit comments

Comments
 (0)