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 integration for custom tracking of flag evaluations #3860

Merged
merged 24 commits into from
Dec 19, 2024

Conversation

aliu39
Copy link
Member

@aliu39 aliu39 commented Dec 5, 2024

Follow-up to

  1. Adds an integration for buffering feature flags manually with an API (add_feature_flag), and automatically capturing them on error events.

  2. Adds improved test coverage to launchdarkly and openfeature by testing end to end with capture_events fixture, rather than asserting the flags are stored to scope.

@aliu39 aliu39 requested a review from cmanallen December 5, 2024 19:57
Copy link

codecov bot commented Dec 5, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
13801 1 13800 4139
View the top 1 failed tests by shortest run time
tests.integrations.launchdarkly.test_launchdarkly test_launchdarkly_integration[False]
Stack Traces | 0.337s run time
.../integrations/launchdarkly/test_launchdarkly.py:48: in test_launchdarkly_integration
    assert len(events) == 1
E   AssertionError: assert 2 == 1
E    +  where 2 = len([{'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': '91e2f801598b1cc5', 'trace_id': 'ec3ee1fd20f64251aee47ef1bfa3b656'}}, 'environment': 'production', 'event_id': '22cbdbda740f4333bc4a24d9477cd58f', ...}, {'breadcrumbs': {'values': []}, 'contexts': {'flags': {'values': [{'flag': 'hello', 'result': True}, {'flag': 'world', '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': '91e2f801598b1cc5', 'trace_id': 'ec3ee1fd20f64251aee47ef1bfa3b656'}}, 'environment': 'production', 'event_id': 'b5b7269cd45740ad89573390823dbcbd', ...}])

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

sentry_sdk/integrations/featureflags.py Show resolved Hide resolved
tests/integrations/featureflags/test_featureflags.py Outdated Show resolved Hide resolved
tests/test_lru_cache.py Outdated Show resolved Hide resolved
sentry_sdk/_lru_cache.py Outdated Show resolved Hide resolved
@aliu39 aliu39 changed the title Aliu/ff integration and added coverage feat(flags): Add integration for custom tracking of flag evaluations Dec 5, 2024
@aliu39 aliu39 force-pushed the aliu/ff-integration-and-added-coverage branch from 320e49e to 4651b6a Compare December 6, 2024 19:05
@aliu39 aliu39 requested a review from cmanallen December 6, 2024 19:31
@aliu39 aliu39 marked this pull request as ready for review December 6, 2024 19:31
@aliu39 aliu39 requested review from antonpirker and a team December 6, 2024 19:57
sentry_sdk/integrations/featureflags.py Outdated Show resolved Hide resolved
tests/integrations/featureflags/test_featureflags.py Outdated Show resolved Hide resolved
@aliu39 aliu39 requested a review from cmanallen December 6, 2024 20:18


@pytest.fixture
def uninstall_integration():
Copy link
Member Author

@aliu39 aliu39 Dec 6, 2024

Choose a reason for hiding this comment

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

Note on this fixture: I found using the reset_integrations fixture in conftest.py caused issues with the default dedupe integration. We just want the integration being tested to be setup at the start of every new test.

Without using this, the error processor isn't added correctly. This isn't a concern for real use, since user apps only call init once

Copy link
Member

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

Looks OK

@antonpirker
Copy link
Member

We also need to add docs for this, can you prepare a PR in the docs repo?

@aliu39
Copy link
Member Author

aliu39 commented Dec 18, 2024

Sounds good! I've opened getsentry/sentry-docs#12152, will do a last check in the morning to make sure it's up to date!

@aliu39
Copy link
Member Author

aliu39 commented Dec 18, 2024

Do you know anything about the failing ubuntu tests @antonpirker ?

@antonpirker
Copy link
Member

Do you know anything about the failing ubuntu tests @antonpirker ?

In Python 3.6 there is probably no asyncio.run().

Can you fix this somehow, or skip this test in Python 3.6 (then this integration will only be supported form Python 3.7 and up)

@aliu39 aliu39 enabled auto-merge (squash) December 19, 2024 04:00
@aliu39 aliu39 disabled auto-merge December 19, 2024 04:00
@aliu39 aliu39 enabled auto-merge (squash) December 19, 2024 04:01
@aliu39 aliu39 merged commit 50222ca into master Dec 19, 2024
134 of 135 checks passed
@aliu39 aliu39 deleted the aliu/ff-integration-and-added-coverage branch December 19, 2024 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants