Skip to main content

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?

a simple celery task that takes a while

More Questions?

Please open an issue or drop a message on my socials, will be happy to help.

LinkedIn X

How to publish

  • poetry build
  • poetry config pypi-token.pypi
  • poetry publish

Metadata

Release files for celery-sqlcommenter 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for celery-sqlcommenter 0.2
File Size Uploaded
celery_sqlcommenter-0.2.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for celery-sqlcommenter 0.2
File Interpreter ABI Platform
celery_sqlcommenter-0.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / celery_sqlcommenter-0.2.tar.gz

Download URL celery_sqlcommenter-0.2.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cfdcc25840c5890fba6a7b779759fbd068a4d2a5e20f6a0654837596247ae546
BLAKE2b-256 checksum
How to use checksums
561ec0629d1f8afba115ea823b87d0d00892aaec71dcc8b0ffbbd61699512765
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.13.5 Darwin/24.6.0

Release files / celery_sqlcommenter-0.2-py3-none-any.whl

Download URL celery_sqlcommenter-0.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e17e5407dc2586bbb2e6df932b21480b4e748202a02752c35e6d6433d9cd382
BLAKE2b-256 checksum
How to use checksums
dc9d3b90645dd7ac6b8216df3592c8952d72219a4ca6435ded7335adb817b6cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.13.5 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page