Python ASGI Monitoring

From the ASGI Documentation:

ASGI (Asynchronous Server Gateway Interface) is a spiritual successor to WSGI, intended to provide a standard interface between async-capable Python web servers, frameworks, and applications.

The Instana Python package bundles an ASGI compliant middleware that provides request visibily into your asynchronous applications.

Please note that for FastAPI and Starlette based applications, the ASGI middleware is applied automatically. See the related pages for more details.


The Instana ASGI middleware is available at instana.middleware.InstanaASGIMiddleware and can be used with any ASGI compliant application.

See the opensource code that implements this on Github in the instana/python-sensor repository.


import uvicorn
from instana.middleware import InstanaASGIMiddleware

# ...application definition code...

# Wrap the ASGI application with the Instana ASGI middleware
application = InstanaASGIMiddleware(application), host='', port=80)

See Also