Skip to content

feat: report feature flag evaluation to Sentry#117

Open
bardiharborow wants to merge 1 commit into
mainfrom
feature/report-feature-flag-evaluation-to-sentry
Open

feat: report feature flag evaluation to Sentry#117
bardiharborow wants to merge 1 commit into
mainfrom
feature/report-feature-flag-evaluation-to-sentry

Conversation

@bardiharborow

Copy link
Copy Markdown
Contributor

This PR adds custom feature flag classes to django-waffle that report feature flag evaluation to Sentry. Sentry attaches the reported flags to error and transaction events for the current request, making it possible to see which feature flags were active when an error occurred.

See also: https://docs.sentry.io/product/issues/issue-details/feature-flags/

This commit adds custom feature flag classes to django-waffle that report feature flag evaluation to Sentry. Sentry attaches the reported flags to error and transaction events for the current request, making it possible to see which feature flags were active when an error occurred.
@bardiharborow bardiharborow added the enhancement New feature or request label Jun 10, 2026

@a-musing-moose a-musing-moose left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the failing test and the module import convention thing, this looks good.

Since we now have both waffle and this new flags app in INSTALLED_APPS does that mean admin will show both sets of models? Is there any way to avoid that?


from django.http import HttpRequest
from sentry_sdk.feature_flags import add_feature_flag
from waffle.models import (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Please import modules, not individual properties

As per Python Coding Conventions we want to preference the importing of modules. The odd single import (like HttpRequest) is fine, but when you start needing multiple lines I would prefer to enforce this convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants