Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(flags): add Unleash feature flagging integration #3888

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

aliu39
Copy link
Member

@aliu39 aliu39 commented Dec 21, 2024

Adds an integration for tracking flag evaluations from Unleash customers.

Implementation
Unleash has no native support for evaluation hooks/listeners, unless the user opts in for each flag. Therefore we decided to patch the is_enabled and get_variant methods on the UnleashClient class. The methods are wrapped and the only side effect is writing to Sentry scope, so users shouldn't see any change in behavior.

We patch one UnleashClient instance instead of the whole class. The reasons for this are described in

It's also safer to not modify the unleash import.

References

Copy link

codecov bot commented Dec 21, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
13815 1 13814 4140
View the top 1 failed tests by shortest run time
tests.integrations.launchdarkly.test_launchdarkly test_launchdarkly_integration_threaded
Stack Traces | 0.113s run time
.../integrations/launchdarkly/test_launchdarkly.py:90: in test_launchdarkly_integration_threaded
    assert len(events) == 3
E   AssertionError: assert 5 == 3
E    +  where 5 = len([{'breadcrumbs': {'values': []}, 'contexts': {'flags': {'values': [{'flag': 'hello', 'result': True}, {'flag': 'world', 'result': False}]}, 'runtime': {'build': '3.12.8 (main, Dec  4 2024, 06:20:10) [GCC 9.4.0]', 'name': 'CPython', 'version': '3.12.8'}, 'trace': {'parent_span_id': None, 'span_id': 'a438de914ef4df07', 'trace_id': 'f866dac9f19441b086d82351ab420acb'}}, 'environment': 'production', 'event_id': '96f0d44cc36846478eec9f67f4819998', ...}, {'breadcrumbs': {'values': []}, 'contexts': {'runtime': {'build': '3.12.8 (main, Dec  4 2024, 06:20:10) [GCC 9.4.0]', 'name': 'CPython', 'version': '3.12.8'}, 'trace': {'parent_span_id': None, 'span_id': 'accefc5ba7509f4c', 'trace_id': 'e9c98b5b272e4d2fb389d0c9c9696007'}}, 'environment': 'production', 'event_id': 'ba881380d851456f8fc16a4278bcc0f1', ...}, {'breadcrumbs': {'values': []}, 'contexts': {'runtime': {'build': '3.12.8 (main, Dec  4 2024, 06:20:10) [GCC 9.4.0]', 'name': 'CPython', 'version': '3.12.8'}, 'trace': {'parent_span_id': None, 'span_id': 'accefc5ba7509f4c', 'trace_id': 'e9c98b5b272e4d2fb389d0c9c9696007'}}, 'environment': 'production', 'event_id': '054f1cf36bb74e8bbb0b4efd57e8999e', ...}, {'breadcrumbs': {'values': []}, 'contexts': {'flags': {'values': [{'flag': 'hello', 'result': True}, {'flag': 'other', 'result': False}]}, 'runtime': {'build': '3.12.8 (main, Dec  4 2024, 06:20:10) [GCC 9.4.0]', 'name': 'CPython', 'version': '3.12.8'}, 'trace': {'parent_span_id': None, 'span_id': 'a438de914ef4df07', 'trace_id': 'f866dac9f19441b086d82351ab420acb'}}, 'environment': 'production', 'event_id': 'af8ddef4e0c444ad82de4cd78cc672ff', ...}, {'breadcrumbs': {'values': []}, 'contexts': {'flags': {'values': [{'flag': 'hello', 'result': True}]}, 'runtime': {'build': '3.12.8 (main, Dec  4 2024, 06:20:10) [GCC 9.4.0]', 'name': 'CPython', 'version': '3.12.8'}, 'trace': {'parent_span_id': None, 'span_id': 'a438de914ef4df07', 'trace_id': 'f866dac9f19441b086d82351ab420acb'}}, 'environment': 'production', 'event_id': '2113cb8a9748455f93e3e56fe088452a', ...}])

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@aliu39 aliu39 added the New Integration Integrating with a new framework or library label Dec 22, 2024
@aliu39 aliu39 marked this pull request as ready for review December 23, 2024 04:51
@aliu39 aliu39 requested review from antonpirker, cmanallen and a team December 23, 2024 04:52
@antonpirker
Copy link
Member

Hey @aliu39 ! Thanks for the integration. This will be reviewed after the holiday season.

@aliu39
Copy link
Member Author

aliu39 commented Dec 23, 2024

Todo:

  • verify w manual test
  • threading and asyncio tests
  • determine if variant payload should factor into tracking (no, track every feature)
  • docs w/ sample verification code

@getsentry getsentry locked and limited conversation to collaborators Dec 27, 2024
@getsentry getsentry unlocked this conversation Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Integration Integrating with a new framework or library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants