コンテンツにスキップ

AIO HTTPクライアント

AIO HTTPは、asyncioおよびPython用の非同期HTTPクライアント/サーバーフレームワークです。

logfire.instrument_aiohttp_client() このメソッドは、AIO HTTPクライアントによって発行されたリクエストごとにスパンを作成します。

問題

AIO HTTPサーバーはどうですか?現在、AIO HTTPサーバーのプラグインはサポートされていません。はここでで進捗状況を追跡できます。

インストール

aiohttp extraを使用して logfire をインストールする:

{{ install_logfire(extras=['aiohttp']) }}

使い方

次の最小の例を見てみましょう。python main.py を使用して実行できます:

main.py
import logfire
import aiohttp


logfire.configure()
logfire.instrument_aiohttp_client()


async def main():
    async with aiohttp.ClientSession() as session:
        await session.get("https://httpbin.org/get")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

logfire.instrument_aiohttp_client() のキーワードパラメータは、OpenTelemetyaiohttpクライアントのInstrumentationパッケージの AioHttpClientInstrumentor().instrument() メソッドに渡されます。については、ここで詳しく読んでください。


本文总阅读量次