Skip to content

Missing asgiref dependency when installing fastapi instrumentation from 0.25b0 #764

@AntoineDao

Description

@AntoineDao

Describe your environment Describe any aspect of your environment relevant to the problem, including your Python version, platform, version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main.

Here is a review of my environment:

  • Python version: 3.7.12
  • OS: python:3.7 Docker image base
  • Python dependencies in the form of a requirements.txt file:
fastapi>=0.63.0
PyJWT==1.7.1
python-dotenv==0.11.0
uvicorn==0.6.1
async-exit-stack==1.0.1
async-generator==1.10
cryptography==2.9.2
starlette-context==0.3.1
cloudevents==1.2.0
aiohttp==3.7.4.post0
google-cloud-secret-manager==2.2.0
asgiref
opentelemetry-instrumentation-aiohttp-client
opentelemetry-instrumentation-botocore
opentelemetry-instrumentation-fastapi
opentelemetry-instrumentation-requests
opentelemetry-instrumentation-sqlalchemy
opentelemetry-exporter-gcp-trace==1.0.0
opentelemetry-propagator-gcp==1.0.0

Steps to reproduce
I use the Fastapi Instrumentation which depends on the opentelemetry-instrumentation-asgi package. I run into an import error when I try to import the Fastapi instrumentation package:

from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
  File "/usr/src/app/app/server/application.py", line 8, in <module>
    from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
  File "/usr/local/lib/python3.7/site-packages/opentelemetry/instrumentation/fastapi/__init__.py", line 22, in <module>
    from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware
  File "/usr/local/lib/python3.7/site-packages/opentelemetry/instrumentation/asgi/__init__.py", line 26, in <module>
    from asgiref.compatibility import guarantee_single_callable
ModuleNotFoundError: No module named 'asgiref'

What is the expected behavior?
Not an import error 😛

What is the actual behavior?
An import error 😭

Additional context
I am fairly certain the breaking change is introduced in 0.25.b0 version of the opentelemtry python contrib package. I tested this by setting fixed versions to my requirements.txt file and going back a version each time while rebuilding the docker container.

I tried looking into the diff between 0.24b0 and 0.25b0 releases but couldn't find anything that would indicate some dependency import issues...

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