HTTPX
The HTTPX integration instruments outgoing HTTP requests using either the sync or the async HTTPX clients.
Use this integration to create spans for outgoing requests and ensure traces are properly propagated to downstream services.
Install sentry-sdk
from PyPI with the httpx
extra.
Copied
pip install --upgrade 'sentry-sdk[httpx]'
Copied
import sentry_sdk
sentry_sdk.init(
dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
enable_tracing=True,
)
The HTTPX integration is enabled automatically if you have the httpx
package installed.
Copied
import httpx
def main():
sentry_init(...) # same as above
with sentry_sdk.start_transaction(name="testing_sentry"):
r1 = httpx.get("https://sentry.io/")
r2 = httpx.post("http://httpbin.org/post")
main()
This will create a transaction called testing_sentry
in the Performance section of sentry.io, and create spans for the outgoing HTTP requests.
It takes a couple of moments for the data to appear in sentry.io.
- HTTPX: 0.16+
- Python: 3.6+
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
- Package:
- pypi:sentry-sdk
- Version:
- 2.0.0
- Repository:
- https://github.com/getsentry/sentry-python
- API Documentation:
- https://getsentry.github.io/sentry-python/