Skip to content

Add Prometheus metrics for HTTPX requests#130

Merged
openminddev merged 1 commit into
mainfrom
add-httpx-prometheus
May 28, 2026
Merged

Add Prometheus metrics for HTTPX requests#130
openminddev merged 1 commit into
mainfrom
add-httpx-prometheus

Conversation

@openminddev

Copy link
Copy Markdown
Contributor

Add a new prometheus metrics module and hook it into HTTPX event handlers. Created src/om1_utils/prometheus/init.py which defines Histograms and Gauges for request duration, upstream total, upstream TTFB, and proxy total (including _last_seconds gauges). Updated src/om1_utils/httpx/init.py to import these metrics, handle missing request start_time (log a warning and skip metrics), compute elapsed time, and record observe/set metrics by parsing relevant response headers (convert ms to seconds and ignore invalid values).

Add a new prometheus metrics module and hook it into HTTPX event handlers. Created src/om1_utils/prometheus/__init__.py which defines Histograms and Gauges for request duration, upstream total, upstream TTFB, and proxy total (including `_last_seconds` gauges). Updated src/om1_utils/httpx/__init__.py to import these metrics, handle missing request start_time (log a warning and skip metrics), compute elapsed time, and record observe/set metrics by parsing relevant response headers (convert ms to seconds and ignore invalid values).
@openminddev openminddev merged commit c600731 into main May 28, 2026
7 checks passed
@openminddev openminddev deleted the add-httpx-prometheus branch May 28, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant