Skip to content

Commit

Permalink
fix: Unify queue name label
Browse files Browse the repository at this point in the history
For celery queue length the queue name label is `queue_name`.
  • Loading branch information
adinhodovic authored and danihodovic committed Jan 20, 2023
1 parent 7290da5 commit 5775bd5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions charts/celery-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]

Expand Down
20 changes: 10 additions & 10 deletions src/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
}
Expand All @@ -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,
)
Expand Down Expand Up @@ -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():
Expand Down
18 changes: 9 additions & 9 deletions src/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5775bd5

Please sign in to comment.