Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #14 from managedbyq/fix-queue-metrics
Browse files Browse the repository at this point in the history
Fix queue metrics
  • Loading branch information
sashako authored Sep 26, 2018
2 parents d08c0ba + 0925599 commit 50e8456
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mbq/atomiq/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
__license__ = 'Apache 2.0'
__title__ = 'mbq.atomiq'
__url__ = 'https://github.com/managedbyq/mbq.atomiq'
__version__ = '0.0.4'
__version__ = '0.0.5'
8 changes: 5 additions & 3 deletions mbq/atomiq/management/commands/atomic_run_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def collect_metrics(self, **options):
model = self.consumers[queue_type].model

state_counts = collections.Counter(model.objects.values_list('state', flat=True))
for state, count in state_counts.items():
task_states = (state[0] for state in constants.TaskStates.CHOICES)

for task_state in task_states:
_collector.gauge(
'state_total',
count,
tags={'state': state, 'queue_type': queue_type},
state_counts.get(task_state, 0),
tags={'state': task_state, 'queue_type': queue_type},
)

def handle(self, *args, **options):
Expand Down

0 comments on commit 50e8456

Please sign in to comment.