Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aiohttp-server instrumentation doesn't work with several types of importing #3221

Open
nesb1 opened this issue Jan 30, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@nesb1
Copy link
Contributor

nesb1 commented Jan 30, 2025

Describe your environment

Problem not related to the environment

What happened?

Instrumentation doesn't work with several types of importing. Problem with injecting technique through setattr. Looks like it not the best solution because not works with some imports variants.

Steps to Reproduce

from aiohttp import web
from aiohttp.web import Application
from aiohttp.web_app import Application as ApplicationFromWebApp
from aiohttp import web_app

print(web.Application)
print(Application)
print(web_app.Application)
print(ApplicationFromWebApp)


from opentelemetry.instrumentation.aiohttp_server import AioHttpServerInstrumentor

AioHttpServerInstrumentor().instrument()

print("instrumentation enable")

print(web.Application)
print(Application)
print(web_app.Application)
print(ApplicationFromWebApp)

Expected Result

<class 'aiohttp.web_app.Application'>
<class 'aiohttp.web_app.Application'>
<class 'aiohttp.web_app.Application'>
<class 'aiohttp.web_app.Application'>
instrumentation enable
<class 'opentelemetry.instrumentation.aiohttp_server._InstrumentedApplication'>
<class 'opentelemetry.instrumentation.aiohttp_server._InstrumentedApplication'>
<class 'opentelemetry.instrumentation.aiohttp_server._InstrumentedApplication'>
<class 'opentelemetry.instrumentation.aiohttp_server._InstrumentedApplication'>

Actual Result

<class 'aiohttp.web_app.Application'>
<class 'aiohttp.web_app.Application'>
<class 'aiohttp.web_app.Application'>
<class 'aiohttp.web_app.Application'>
instrumentation enable
<class 'opentelemetry.instrumentation.aiohttp_server._InstrumentedApplication'>
<class 'aiohttp.web_app.Application'>
<class 'aiohttp.web_app.Application'>
<class 'aiohttp.web_app.Application'>

Additional context

No response

Would you like to implement a fix?

yes

@nesb1 nesb1 added the bug Something isn't working label Jan 30, 2025
@nesb1 nesb1 changed the title aiohttp-server instrumentation does not works with some imports aiohttp-server instrumentation doesn't work with several types of importing Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant