From 5775bd5cbd00747ab3fc5be3213ac267ec549d30 Mon Sep 17 00:00:00 2001 From: adinhodovic Date: Fri, 20 Jan 2023 16:12:12 +0100 Subject: [PATCH] fix: Unify queue name label For celery queue length the queue name label is `queue_name`. --- charts/celery-exporter/Chart.yaml | 4 ++-- pyproject.toml | 2 +- src/exporter.py | 20 ++++++++++---------- src/test_cli.py | 18 +++++++++--------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/charts/celery-exporter/Chart.yaml b/charts/celery-exporter/Chart.yaml index 866fd3d..56c8ac9 100644 --- a/charts/celery-exporter/Chart.yaml +++ b/charts/celery-exporter/Chart.yaml @@ -13,5 +13,5 @@ maintainers: - name: danihodovic - name: adinhodovic -version: 0.6.1 -appVersion: 0.7.1 +version: 0.6.2 +appVersion: 0.7.2 diff --git a/pyproject.toml b/pyproject.toml index aed04b0..8a600d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ skip = '.virtualenv,.venv,.poetry,.poetry-cache' [tool.poetry] name = "celery-exporter" -version = "0.7.1" +version = "0.7.2" description = "" authors = ["Dani Hodovic "] diff --git a/src/exporter.py b/src/exporter.py index cc96faa..d8726b7 100644 --- a/src/exporter.py +++ b/src/exporter.py @@ -24,50 +24,50 @@ def __init__(self, buckets=None): "task-sent": Counter( "celery_task_sent", "Sent when a task message is published.", - ["name", "hostname", "queue"], + ["name", "hostname", "queue_name"], registry=self.registry, ), "task-received": Counter( "celery_task_received", "Sent when the worker receives a task.", - ["name", "hostname", "queue"], + ["name", "hostname", "queue_name"], registry=self.registry, ), "task-started": Counter( "celery_task_started", "Sent just before the worker executes the task.", - ["name", "hostname", "queue"], + ["name", "hostname", "queue_name"], registry=self.registry, ), "task-succeeded": Counter( "celery_task_succeeded", "Sent if the task executed successfully.", - ["name", "hostname", "queue"], + ["name", "hostname", "queue_name"], registry=self.registry, ), "task-failed": Counter( "celery_task_failed", "Sent if the execution of the task failed.", - ["name", "hostname", "exception", "queue"], + ["name", "hostname", "exception", "queue_name"], registry=self.registry, ), "task-rejected": Counter( "celery_task_rejected", # pylint: disable=line-too-long "The task was rejected by the worker, possibly to be re-queued or moved to a dead letter queue.", - ["name", "hostname", "queue"], + ["name", "hostname", "queue_name"], registry=self.registry, ), "task-revoked": Counter( "celery_task_revoked", "Sent if the task has been revoked.", - ["name", "hostname", "queue"], + ["name", "hostname", "queue_name"], registry=self.registry, ), "task-retried": Counter( "celery_task_retried", "Sent if the task failed, but will be retried in the future.", - ["name", "hostname", "queue"], + ["name", "hostname", "queue_name"], registry=self.registry, ), } @@ -86,7 +86,7 @@ def __init__(self, buckets=None): self.celery_task_runtime = Histogram( "celery_task_runtime", "Histogram of task runtime measurements.", - ["name", "hostname", "queue"], + ["name", "hostname", "queue_name"], registry=self.registry, buckets=buckets or Histogram.DEFAULT_BUCKETS, ) @@ -148,7 +148,7 @@ def track_task_event(self, event): labels = { "name": task.name, "hostname": get_hostname(task.hostname), - "queue": getattr(task, "queue", "celery"), + "queue_name": getattr(task, "queue", "celery"), } for counter_name, counter in self.state_counters.items(): diff --git a/src/test_cli.py b/src/test_cli.py index 6bc5a43..ec1d149 100644 --- a/src/test_cli.py +++ b/src/test_cli.py @@ -49,39 +49,39 @@ def fail(): assert res.status_code == 200 # pylint: disable=line-too-long assert ( - f'celery_task_sent_total{{hostname="{hostname}",name="src.test_cli.succeed",queue="celery"}} 2.0' + f'celery_task_sent_total{{hostname="{hostname}",name="src.test_cli.succeed",queue_name="celery"}} 2.0' in res.text ) assert ( - f'celery_task_sent_total{{hostname="{hostname}",name="src.test_cli.fail",queue="celery"}} 1.0' + f'celery_task_sent_total{{hostname="{hostname}",name="src.test_cli.fail",queue_name="celery"}} 1.0' in res.text ) assert ( - f'celery_task_received_total{{hostname="{hostname}",name="src.test_cli.succeed",queue="celery"}} 2.0' + f'celery_task_received_total{{hostname="{hostname}",name="src.test_cli.succeed",queue_name="celery"}} 2.0' in res.text ) assert ( - f'celery_task_received_total{{hostname="{hostname}",name="src.test_cli.fail",queue="celery"}} 1.0' + f'celery_task_received_total{{hostname="{hostname}",name="src.test_cli.fail",queue_name="celery"}} 1.0' in res.text ) assert ( - f'celery_task_started_total{{hostname="{hostname}",name="src.test_cli.succeed",queue="celery"}} 2.0' + f'celery_task_started_total{{hostname="{hostname}",name="src.test_cli.succeed",queue_name="celery"}} 2.0' in res.text ) assert ( - f'celery_task_started_total{{hostname="{hostname}",name="src.test_cli.fail",queue="celery"}} 1.0' + f'celery_task_started_total{{hostname="{hostname}",name="src.test_cli.fail",queue_name="celery"}} 1.0' in res.text ) assert ( - f'celery_task_succeeded_total{{hostname="{hostname}",name="src.test_cli.succeed",queue="celery"}} 2.0' + f'celery_task_succeeded_total{{hostname="{hostname}",name="src.test_cli.succeed",queue_name="celery"}} 2.0' in res.text ) assert ( - f'celery_task_failed_total{{exception="HTTPError",hostname="{hostname}",name="src.test_cli.fail",queue="celery"}} 1.0' + f'celery_task_failed_total{{exception="HTTPError",hostname="{hostname}",name="src.test_cli.fail",queue_name="celery"}} 1.0' in res.text ) assert ( - f'celery_task_runtime_count{{hostname="{hostname}",name="src.test_cli.succeed",queue="celery"}} 2.0' + f'celery_task_runtime_count{{hostname="{hostname}",name="src.test_cli.succeed",queue_name="celery"}} 2.0' in res.text ) assert 'celery_queue_length{queue_name="celery"} 0.0' in res.text