instrument sql queries running on celery
Project description
celery-sqlcommenter
Attach SQL comments to correlate celery tasks with SQL statements.
This helps in easily correlating slow performance with async tasks and giving insights into backend database performance. In short it provides some observability into the state of your client-side applications and their impact on the database’s server-side.
When to use?
You're using celery with django, and want to trace the origin of database queries.
Does it replace / overlap sqlcommenter
No. I've been using sqlcommenter in production and it lacked the ability to annotate queries that were run in non-http context. Meaning all queries that originated from async flows were untagged.
This package fills that gap.
How to use
In a simple celery setup, just passing the BaseTask when declaring a celery object will do the job.
# if not using a base class, pass directly where you declare celery config
from celery_sqlcommenter import BaseTask
app = Celery("my-awsome-application", task_cls=BaseTask)
If you already have a custom BaseTask with specific functionality, replace the original celery.Task with celery_sqlcommenter.BaseTask
# old configuration
from celery import Task
class MyBaseTask(Task):
# custom methods you've implemented
def on_failure(self, exc, task_id, args, kwargs):
pass
# simply replace Task with BaseTask provided by the package
from celery_sqlcommenter import BaseTask
# notice Task changed to BaseTask
class MyBaseTask(BaseTask):
# custom methods you've implemented
def on_failure(self, exc, task_id, args, kwargs):
pass
Internally BaseTask inherits celery.Task so all functionality stays intact
How to install
Install the package from pypi
# vanilla
pip install celery-sqlcommenter
# poetry
poetry add celery-sqlcommenter
How does it look live?
More Questions?
Please open an issue or drop a message on my socials, will be happy to help.
How to publish
- poetry build
- poetry config pypi-token.pypi
- poetry publish
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file celery_sqlcommenter-0.1.3.tar.gz.
File metadata
- Download URL: celery_sqlcommenter-0.1.3.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.5 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c66ffedf2e143177b95dbd35911a547e5236ab31290131cfd953b04c10dbc411
|
|
| MD5 |
7da5ad311b293a31343f2b55bf7894db
|
|
| BLAKE2b-256 |
59f26a7f77ee555ce8115f761ae8171da1208d31dc4c613fe737db573e561b92
|
File details
Details for the file celery_sqlcommenter-0.1.3-py3-none-any.whl.
File metadata
- Download URL: celery_sqlcommenter-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.5 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f04de5b04eef2d587048c12e6e71c5fd8f97eb5861fec4c6545e4cde3b8b4a94
|
|
| MD5 |
2ef4e363c4170615280281431f404c8b
|
|
| BLAKE2b-256 |
8e67ab69a4dfc39bb7f640c11d1184d682312b08198f87c6a789b25068adb352
|