openwisp / openwisp-monitoring

Network monitoring system written in Python and Django, designed to be extensible, programmable, scalable and easy to use by end users: once the system is configured, monitoring checks, alerts and metric collection happens automatically.
https://openwisp.io/docs/dev/monitoring/
Other
167 stars 114 forks source link

[change] Rename celery tasks _timeseries_write and _timeseries_batch_write #569

Closed nemesifier closed 7 months ago

nemesifier commented 7 months ago

Given the following ROUTES setting:

CELERY_TASK_ROUTES = {
        # timeseries writing
        'openwisp_monitoring.monitoring.tasks.*': {'queue': 'manager'},
}

We would expect that tasks are routed to the manager queue but the following two tasks are still routed to the default queue:

This has unexpected consequences.

It may be caused by the leading underscore in the task name. If that's the case it would be appropriate to remove the leading underscore and make sure functions used internally are using the underscore.

nemesifier commented 7 months ago

I think the problem I mentioned above may not be caused by the naming of the tasks, but nonetheless it would be good to make sure to go ahead with the change anyway to maintain consistency across the codebase: we don't have any celery task which is named with a leading underscore.

The functions that write metrics can be flagged as private as we may change this mechanism over time, but we haven't been changing celery tasks very often, usually once a task is added we almost never remove it or rename it except on rare occasions.