Skip to content

DeprecationWarning: Inheritance class _InstrumentedApplication from web.Application is discouraged in aiohttp-server instrumentation #2859

Open
@phillipuniverse

Description

@phillipuniverse

Describe your environment

OS: MacOS
Python version: Python 3.11.8
Package version: 0.48b0

What happened?

Getting a deprecation warning when activating aiohttp-server instrumentation target aiohttp 3.9.3:

DeprecationWarning: Inheritance class _InstrumentedApplication from web.Application is discouraged

Steps to Reproduce

Use auto-instrumentation for the aiohttp library after including opentelemetry-instrumentation-aiohttp.

Expected Result

No deprecation warning

Actual Result

Following stack trace (with warnings turned into errors from Pytest):

Traceback (most recent call last):
  File "/Users/phillip/Library/Caches/pypoetry/virtualenvs/shipwell-common-python-zjZyLK7l-py3.11/lib/python3.11/site-packages/opentelemetry/instrumentation/auto_instrumentation/_load.py", line 87, in _load_instrumentors
    distro.load_instrumentor(entry_point, skip_dep_check=True)
  File "/Users/phillip/Library/Caches/pypoetry/virtualenvs/shipwell-common-python-zjZyLK7l-py3.11/lib/python3.11/site-packages/opentelemetry/instrumentation/distro.py", line 63, in load_instrumentor
    instrumentor: BaseInstrumentor = entry_point.load()
                                     ^^^^^^^^^^^^^^^^^^
  File "/Users/phillip/Library/Caches/pypoetry/virtualenvs/shipwell-common-python-zjZyLK7l-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py", line 2496, in load
    return self.resolve()
           ^^^^^^^^^^^^^^
  File "/Users/phillip/Library/Caches/pypoetry/virtualenvs/shipwell-common-python-zjZyLK7l-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py", line 2502, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/phillip/Library/Caches/pypoetry/virtualenvs/shipwell-common-python-zjZyLK7l-py3.11/lib/python3.11/site-packages/opentelemetry/instrumentation/aiohttp_server/__init__.py", line 242, in <module>
    class _InstrumentedApplication(web.Application):
  File "<frozen abc>", line 106, in __new__
  File "/Users/phillip/Library/Caches/pypoetry/virtualenvs/shipwell-common-python-zjZyLK7l-py3.11/lib/python3.11/site-packages/aiohttp/web_app.py", line 161, in __init_subclass__
    warnings.warn(
DeprecationWarning: Inheritance class _InstrumentedApplication from web.Application is discouraged

Additional context

It appears this ends up breaking all http instrumentation, should this be a bit of a softer error and only break this specific instrumentation? Meaning this re-raise:

except Exception as exc: # pylint: disable=broad-except
_logger.exception("Instrumenting of %s failed", entry_point.name)
raise exc

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions