opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

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

Open phillipuniverse opened this issue 1 year ago • 2 comments
trafficstars

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:

https://github.com/open-telemetry/opentelemetry-python-contrib/blob/6f1a17d8dd5d2f2f51cfe9d65e57cc8d16632154/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py#L89-L91

Would you like to implement a fix?

None

phillipuniverse avatar Sep 10 '24 19:09 phillipuniverse