feat(process_label): add process role labeling for PostgreSQL connections

- Introduced a new module to determine the process role based on command-line arguments, enhancing PostgreSQL connection labeling for better monitoring.
- Updated the database connection parameters to include the application name derived from the process role.
- Added unit tests to validate the process role detection logic for different scenarios, including Celery and uWSGI.
This commit is contained in:
SergeantPanda 2026-06-16 11:26:12 -05:00
parent b2496dc4e7
commit c1ff5e35aa
3 changed files with 55 additions and 0 deletions

View file

@ -0,0 +1,18 @@
from unittest.mock import patch
from django.test import SimpleTestCase
from dispatcharr.db.process_label import get_process_role
class ProcessLabelTests(SimpleTestCase):
def test_celery_worker_not_labeled_as_uwsgi(self):
role = get_process_role(
["/dispatcharrpy/bin/celery", "-A", "dispatcharr", "worker"]
)
self.assertEqual(role, "celery-worker")
def test_uwsgi_labeled_when_gevent_support(self):
with patch.dict("os.environ", {"GEVENT_SUPPORT": "True"}):
role = get_process_role(["uwsgi"])
self.assertEqual(role, "uwsgi")