Skip to content

Commit 9627ed5

Browse files
author
bdribault
committed
configurable prom timeout, increase init query timeout
1 parent 7fdc702 commit 9627ed5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/process.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ async def load_metric(metric: Metrics, timestamp, options: Options):
5858
recatch_dots_by_key[key] = last_dot
5959

6060
# Fine tuned query to compute input increments
61-
61+
# Prometheus needs some time to process this complex query, so we use a longer timeout
6262
query = (
6363
"query_range?query="
6464
+ metric.get_query()
6565
+ f"&start={start}&end={timestamp}&step=15s"
6666
)
67-
data = await prom.fetch(query)
67+
data = await prom.fetch(query, timeout=40.0)
6868

6969
for element in data:
7070
labels = element["metric"]

src/prom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class PrometheusException(Exception):
1616
logger = logging.getLogger(__name__)
1717

1818

19-
async def fetch(query: str,) -> dict:
19+
async def fetch(query: str, timeout=20.0) -> dict:
2020
url = PROM_URL + query
2121
try:
22-
async with httpx.AsyncClient(timeout=20.0) as client:
22+
async with httpx.AsyncClient(timeout=timeout) as client:
2323
reply = await client.get(url)
2424
except httpx.RequestError as exc:
2525
raise PrometheusException(

0 commit comments

Comments
 (0)