Skip to content

DeprecationWarning for asyncio.iscoroutinefunction on Python 3.14 HTTPX instrumentation #3879

@phillipuniverse

Description

@phillipuniverse

What problem do you want to solve?

Running with Python 3.14:

.venv/lib/python3.14/site-packages/opentelemetry/instrumentation/auto_instrumentation/__init__.py:170: in initialize
    raise exc
.venv/lib/python3.14/site-packages/opentelemetry/instrumentation/auto_instrumentation/__init__.py:166: in initialize
    _load_instrumentors(distro)
.venv/lib/python3.14/site-packages/opentelemetry/instrumentation/auto_instrumentation/_load.py:149: in _load_instrumentors
    raise exc
.venv/lib/python3.14/site-packages/opentelemetry/instrumentation/auto_instrumentation/_load.py:115: in _load_instrumentors
    distro.load_instrumentor(entry_point, skip_dep_check=True)
.venv/lib/python3.14/site-packages/opentelemetry/instrumentation/distro.py:62: in load_instrumentor
    instrumentor().instrument(**kwargs)
.venv/lib/python3.14/site-packages/opentelemetry/instrumentation/instrumentor.py:125: in instrument
    result = self._instrument(  # pylint: disable=assignment-from-no-return
.venv/lib/python3.14/site-packages/opentelemetry/instrumentation/httpx/__init__.py:894: in _instrument
    if iscoroutinefunction(async_request_hook)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/root/.local/share/uv/python/cpython-3.14.0-linux-aarch64-gnu/lib/python3.14/asyncio/coroutines.py:23: in iscoroutinefunction
    warnings._deprecated("asyncio.iscoroutinefunction",
/root/.local/share/uv/python/cpython-3.14.0-linux-aarch64-gnu/lib/python3.14/_py_warnings.py:830: in _deprecated
    _wm.warn(msg, DeprecationWarning, stacklevel=3)
E   DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead

Describe the solution you'd like

Use inspect.iscoroutinefunction() for Python 3.14+. Here's a similar change in aiohttp.

It looks like we can just wholesale replace, inspect.iscoroutinefunction() has been available since 3.5 - https://docs.python.org/3/library/inspect.html#inspect.iscoroutinefunction

Describe alternatives you've considered

No response

Additional Context

No response

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions