Skip to content

Commit

Permalink
using httpx instead of requests
Browse files Browse the repository at this point in the history
  • Loading branch information
sekharpanja committed Aug 24, 2023
1 parent 8388e94 commit 8a7948e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion prometheus/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN \
chown -R prometheus:prometheus /prometheus && \
apk del .build-deps && \
pip3 install \
requests==2.31.0
httpx==0.24.1

COPY prometheus.yml /etc/prometheus/
COPY fetch_targets.py /
Expand Down
4 changes: 3 additions & 1 deletion prometheus/fetch_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import urllib.parse

import httpx

async def async_main(logger, target_file, url, username, password):
while True:
Expand All @@ -17,7 +18,8 @@ async def async_main(logger, target_file, url, username, password):
b"Authorization": b"Basic "
+ base64.b64encode(f"{username}:{password}".encode("ascii"))
}
response = requests.get(url, headers=headers, stream=True)
async with httpx.AsyncClient() as client:
response = await client.get(url, headers=headers)
response.raise_for_status()
logger.debug("Code %s", response.status_code)
raw_json = response.json()
Expand Down

0 comments on commit 8a7948e

Please sign in to comment.