Skip to content

Commit c5fa83d

Browse files
committed
check that sync hooks are callable
1 parent e7c8efe commit c5fa83d

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
@@ -731,8 +731,12 @@ def _instrument(self, **kwargs):
731731
``async_response_hook``: Async``response_hook`` for ``httpx.AsyncClient``
732732
"""
733733
tracer_provider = kwargs.get("tracer_provider")
734-
self._request_hook = kwargs.get("request_hook")
735-
self._response_hook = kwargs.get("response_hook")
734+
_request_hook = kwargs.get("request_hook")
735+
self._request_hook = _request_hook if callable(_request_hook) else None
736+
_response_hook = kwargs.get("response_hook")
737+
self._response_hook = (
738+
_response_hook if callable(_response_hook) else None
739+
)
736740
_async_request_hook = kwargs.get("async_request_hook")
737741
self._async_request_hook = (
738742
_async_request_hook

0 commit comments

Comments
 (0)