forked from rq/django-rq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export RQ status as prometheus metrics
fixes: rq#503
- Loading branch information
1 parent
87dd8cf
commit 1801c18
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,33 @@ | ||
from django.apps import AppConfig | ||
|
||
from .queues import filter_connection_params, get_connection, get_queue_class, get_unique_connection_configs | ||
from .workers import get_worker_class | ||
|
||
try: | ||
import prometheus_client | ||
|
||
from rq_exporter.collector import RQCollector | ||
except ImportError: | ||
RQCollector = None | ||
|
||
|
||
class DjangoRqAdminConfig(AppConfig): | ||
default_auto_field = "django.db.models.AutoField" | ||
name = "django_rq" | ||
|
||
def ready(self): | ||
if RQCollector is None: | ||
return | ||
|
||
from .settings import QUEUES | ||
|
||
worker_class = get_worker_class() | ||
registered = {} | ||
unique_configs = get_unique_connection_configs() | ||
for name, config in QUEUES.items(): | ||
index = unique_configs.index(filter_connection_params(config)) | ||
queue_class = get_queue_class(config) | ||
key = index, queue_class | ||
if key not in registered: | ||
registered[key] = True | ||
prometheus_client.REGISTRY.register(RQCollector(get_connection(name), worker_class, queue_class)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters