sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

feat(integrations): add django signals_denylist to filter signals that are attached to by signals_span

Open lieryan opened this issue 1 year ago • 0 comments

This PR adds a way to exclude sentry-sdk from attaching to certain Django signals. This can be used to work around performance issues when sentry attaches to performance sensitive signals like pre_init and post_init.

You pass a list of Django signals that you don't want Sentry to attach to:

import django.db.models.signals
import sentry_sdk

sentry_sdk.init(
    ...
    integrations=[
        DjangoIntegration(
            ...
            signals_denylist=[
                django.db.models.signals.pre_init, 
                django.db.models.signals.post_init,
            ],
        ),
    ],
)

This potentially fixes #1826 or #1739, and https://github.com/jazzband/django-model-utils/pull/556.


General Notes

Thank you for contributing to sentry-python!

Please add tests to validate your changes, and lint your code using tox -e linters.

Running the test suite on your PR might require maintainer approval. Some tests (AWS Lambda) additionally require a maintainer to add a special label to run and will fail if the label is not present.

For maintainers

Sensitive test suites require maintainer review to ensure that tests do not compromise our secrets. This review must be repeated after any code revisions.

Before running sensitive test suites, please carefully check the PR. Then, apply the Trigger: tests using secrets label. The label will be removed after any code changes to enforce our policy requiring maintainers to review all code revisions before running sensitive tests.

lieryan avatar Feb 23 '24 13:02 lieryan