diff --git a/instrumentation/opentelemetry-instrumentation-aiokafka/src/opentelemetry/instrumentation/aiokafka/__init__.py b/instrumentation/opentelemetry-instrumentation-aiokafka/src/opentelemetry/instrumentation/aiokafka/__init__.py index 32837b23c5..d4662c9329 100644 --- a/instrumentation/opentelemetry-instrumentation-aiokafka/src/opentelemetry/instrumentation/aiokafka/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aiokafka/src/opentelemetry/instrumentation/aiokafka/__init__.py @@ -95,7 +95,7 @@ async def produce(): from __future__ import annotations -from asyncio import iscoroutinefunction +from inspect import iscoroutinefunction from typing import TYPE_CHECKING, Collection import aiokafka diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py index 4e6257fbb1..948050818c 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py @@ -1,4 +1,4 @@ -import asyncio +import inspect import typing from collections.abc import Coroutine @@ -197,7 +197,7 @@ async def __aenter__(self): async def __aexit__(self, exc_type, exc, t_b): try: - if asyncio.iscoroutinefunction(self._obj.close): + if inspect.iscoroutinefunction(self._obj.close): await self._obj.close() else: self._obj.close() 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 2a82a123f9..67dc9aa960 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py @@ -225,8 +225,8 @@ async def async_response_hook(span, request, response): import logging import typing -from asyncio import iscoroutinefunction from functools import partial +from inspect import iscoroutinefunction from timeit import default_timer from types import TracebackType diff --git a/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py b/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py index e6506d290a..909ec33009 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py +++ b/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py @@ -16,6 +16,7 @@ import abc import asyncio +import inspect import typing from unittest import mock @@ -1086,7 +1087,7 @@ def test_custom_tracer_provider(self): def test_response_hook(self): response_hook_key = ( "async_response_hook" - if asyncio.iscoroutinefunction(self.response_hook) + if inspect.iscoroutinefunction(self.response_hook) else "response_hook" ) response_hook_kwargs = {response_hook_key: self.response_hook} @@ -1133,7 +1134,7 @@ def test_response_hook_sync_async_kwargs(self): def test_request_hook(self): request_hook_key = ( "async_request_hook" - if asyncio.iscoroutinefunction(self.request_hook) + if inspect.iscoroutinefunction(self.request_hook) else "request_hook" ) request_hook_kwargs = {request_hook_key: self.request_hook}