httpx-metrics
httpx-metrics is a utility library that offers classes for integrating metrics into your httpx client (currently, it supports only Prometheus metrics).
Table of Contents
Installation
pip install httpx-metrics
Usage
import httpx
import anyio
from httpx_metrics.async_metrics import (
AsyncDownloadDurationMetric,
AsyncProcessingRequestsMetric,
AsyncRequestsDurationMetric,
AsyncTotalRequestsMetric,
)
from httpx_metrics import AsyncPrometheusTransport
metrics_transport = AsyncPrometheusTransport(
next_transport=httpx.AsyncHTTPTransport(),
metrics=[
AsyncRequestsDurationMetric(),
AsyncTotalRequestsMetric(),
AsyncProcessingRequestsMetric(),
AsyncDownloadDurationMetric(),
],
exporter_port=8000,
)
async def main():
async with httpx.AsyncClient(transport=metrics_transport) as client:
while True:
response = await client.get("https://www.encode.io")
await anyio.sleep(5)
anyio.run(main)
Supported metrics
-
AsyncTotalRequestsMetric / TotalRequestsMetric
Type: Counter
Description: Total number of requests
Labels
- method
- status_code
- path
- version
-
AsyncRequestsDurationMetric / RequestsDurationMetric
Type: Histogram
Description: Request duration in seconds
Labels
- method
- status_code
- path
- version
-
AsyncProcessingRequestsMetric / ProcessingRequestsMetric
Type: Gauge
Description: Number of requests in fly
Labels
- method
- path
-
AsyncDownloadDurationMetric / DownloadDurationMetric
Type: Histogram
Description: Response body downloading duration in seconds
Labels
- method
- status_code
- path
- version
-
AsyncCachedRequestsMetric / CachedRequestsMetric
Note: This metric should be used on top of hishel transports
Type: Counter
Description: Total number of cached requests
Labels
- method
- status_code
- path
- version
- revalidated
Metadata
Release files for httpx-metrics 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| httpx_metrics-0.0.1.tar.gz | 8.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| httpx_metrics-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.7 kB
Release files / httpx_metrics-0.0.1.tar.gz
| Download URL | httpx_metrics-0.0.1.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c933e4b13a2dfbc0aafb502d5edaa0a224376761532e29a2cef1d7b6833b57e7
|
|
BLAKE2b-256 checksum How to use checksums |
9eeba646a6fb3b0f059568f56d130de817346e892552e0a913e78240ab340749
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Release files / httpx_metrics-0.0.1-py3-none-any.whl
| Download URL | httpx_metrics-0.0.1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
972899238a190688a4e9f0b7292eaaa42e94350f0fed1e3788794917e81fc7a4
|
|
BLAKE2b-256 checksum How to use checksums |
7f835704d4ede28bb4f391b07f6a51a713c863be7d52d9369b2a231fb58e6b26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Security for httpx-metrics 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.