Python ASGI 監視

ASGI Documentation:

ASGI (非同步伺服器閘道介面) 是 WSGI 的精神繼承者,旨在提供具有非同步功能的 Python Web 伺服器、架構及應用程式之間的標準介面。

Instana Python 套件組合了 ASGI 相容中介軟體,可將要求 visibily 提供給您的非同步應用程式。

請注意,對於 FastAPIStarlette 型應用程式,會 自動套用 ASGI 中介軟體。 如需詳細資料,請參閱相關頁面。

中介軟體

Instana ASGI 中介軟體位於 instana.middleware.InstanaASGIMiddleware ,可與任何 ASGI 相容應用程式搭配使用。

請參閱 instana/python-sensor 儲存庫中在 Github 上實作此的開放程式碼。

範例

import uvicorn
from instana.middleware import InstanaASGIMiddleware

# ...application definition code...

# Wrap the ASGI application with the Instana ASGI middleware
application = InstanaASGIMiddleware(application)

uvicorn.run(application, host='127.0.0.1', port=80)

另請參閱