Skip to content

Commit

Permalink
fix: backoff on indexer-service metrics HTTP error
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Asseman <[email protected]>
  • Loading branch information
aasseman committed Nov 4, 2022
1 parent 1dde139 commit 45774c1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions autoagora/query_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
)


class HTTPError(Exception):
"""Catch-all for HTTP errors"""


@backoff.on_exception(
backoff.expo, aiohttp.ClientError, max_time=30, logger=logging.root
)
Expand Down Expand Up @@ -52,12 +56,13 @@ async def query_counts() -> Dict[str, int]:


@backoff.on_exception(
backoff.expo, aiohttp.ClientError, max_time=30, logger=logging.root
backoff.expo, (aiohttp.ClientError, HTTPError), max_time=30, logger=logging.root
)
async def subgraph_query_count(subgraph: str) -> int:
async with aiohttp.ClientSession() as session:
async with session.get(args.indexer_service_metrics_endpoint) as response:
assert response.status == 200
if response.status != 200:
raise HTTPError(response.status)

results = re.findall(
r'indexer_service_queries_ok{{deployment="{subgraph}"}} ([0-9]*)'.format(
Expand Down

0 comments on commit 45774c1

Please sign in to comment.