Skip to content

Commit

Permalink
Fix RabbitMQ tests where queue does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
xulaus authored and danihodovic committed Jul 30, 2023
1 parent f787816 commit e50a839
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ def redis_queue_length(connection, queue: str) -> int:


def rabbitmq_queue_length(connection, queue: str) -> int:
return rabbitmq_queue_info(connection, queue).message_count
if queue_info := rabbitmq_queue_info(connection, queue):
return queue_info.message_count
return 0


def queue_length(transport, connection, queue: str) -> Optional[int]:
Expand All @@ -465,7 +467,9 @@ def queue_length(transport, connection, queue: str) -> Optional[int]:


def rabbitmq_queue_consumer_count(connection, queue: str) -> int:
return rabbitmq_queue_info(connection, queue).consumer_count
if queue_info := rabbitmq_queue_info(connection, queue):
return queue_info.consumer_count
return 0


def rabbitmq_queue_info(connection, queue: str):
Expand All @@ -475,5 +479,5 @@ def rabbitmq_queue_info(connection, queue: str):
except ChannelError as ex:
if "NOT_FOUND" in ex.message:
logger.debug(f"Queue '{queue}' not found")
return 0
return None
raise ex

0 comments on commit e50a839

Please sign in to comment.