Zum Inhalt

Mit HTTPX

logfire.instrument_httpx() Methode kann verwendet werden Logfire Prüfung | Die HTTPX。

Installiert

Installieren Sie logfire mit httpx extra :

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

Verwendung

Schauen wir uns ein kleinstes Beispiel an , das Sie mit python main.py ausführen können :

main.py
import logfire
import httpx

logfire.configure()
logfire.instrument_httpx()

url = "https://httpbin.org/get"

with httpx.Client() as client:
    client.get(url)


async def main():
    async with httpx.AsyncClient() as client:
        await client.get(url)


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

logfire.instrument_httpx() Verwendung OpenTelemetry HTTPX-Instrumentierung Pack, das können Sie Hier hier Weitere Informationen zu diesem Paket.

[ HTTPX ] Bearbeitenhttps://www.python-httpx.org/ [ Entelemetry-httpx ] oderhttps://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/httpx/httpx.html


本文总阅读量次