Skip to content

Commit

Permalink
fix: enable raise_for_status, so error handling actually takes place
Browse files Browse the repository at this point in the history
  • Loading branch information
bmario committed Nov 23, 2023
1 parent a968112 commit db07c87
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions metricq_source_rabbitmq/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ async def _update_exchanges(self, session: aiohttp.ClientSession, vhost: str):
except aiohttp.ContentTypeError as exception:
logger.error(f"Can't decode json response! {exception}")
self._last_exchange_timestamp[vhost] = current_exchange_timestamp
except aiohttp.ClientResponseError as exception:
logger.error(f"Request to rabbitmq failed! {exception}")
except aiohttp.ClientConnectorError as exception:
logger.error(f"Can't connect to rabbitmq! {exception}")

Expand Down Expand Up @@ -218,7 +220,8 @@ async def _update_queues(self, session: aiohttp.ClientSession, vhost: str):
)
continue
metric_name = f"{metric_name_prefix}.{count}.count"
logger.debug(f"{metric_name} count is {current_count}")
logger.debug(
f"{metric_name} count is {current_count}")
self[metric_name].append(
current_queue_timestamp, current_count
)
Expand All @@ -243,14 +246,17 @@ async def _update_queues(self, session: aiohttp.ClientSession, vhost: str):
except aiohttp.ContentTypeError as exception:
logger.error(f"Can't decode json response! {exception}")
self._last_queue_timestamp[vhost] = current_queue_timestamp
except aiohttp.ClientResponseError as exception:
logger.error(f"Request to rabbitmq failed! {exception}")
except aiohttp.ClientConnectorError as exception:
logger.error(f"Can't connect to rabbitmq! {exception}")

async def update(self):
auth = None
if self._username and self._password:
auth = aiohttp.BasicAuth(login=self._username, password=self._password)
async with aiohttp.ClientSession(auth=auth) as session:
auth = aiohttp.BasicAuth(
login=self._username, password=self._password)
async with aiohttp.ClientSession(auth=auth, raise_for_status=True) as session:
for vhost in self._vhosts:
await self._update_exchanges(session, vhost)
await self._update_queues(session, vhost)
Expand Down

0 comments on commit db07c87

Please sign in to comment.