Add OpenFeature integration
Adds OpenFeature integration and extends the Scope with a flags property.
As flags are evaluated by an application they are stored within the Sentry SDK (lru cache). When an error occurs we fetch the flags stored in the SDK and serialize them on the event.
Some open questions:
- How do I seed the buffer's capacity from the SDKs (or Integrations) init arguments? Right now its hard-coded at 100. The buffer is stored on the scope so its hard to know which integration should be used.
Codecov Report
Attention: Patch coverage is 89.52381% with 11 lines in your changes missing coverage. Please review.
Project coverage is 84.33%. Comparing base (
d06a189) to head (200917f). Report is 4 commits behind head on master.
:white_check_mark: All tests successful. No failed tests found.
Additional details and impacted files
@@ Coverage Diff @@
## master #3648 +/- ##
==========================================
+ Coverage 84.29% 84.33% +0.04%
==========================================
Files 133 136 +3
Lines 14262 14367 +105
Branches 2405 2417 +12
==========================================
+ Hits 12022 12117 +95
- Misses 1489 1497 +8
- Partials 751 753 +2
| Files with missing lines | Coverage Δ | |
|---|---|---|
| sentry_sdk/_lru_cache.py | 100.00% <100.00%> (ø) |
|
| sentry_sdk/consts.py | 99.51% <ø> (ø) |
|
| sentry_sdk/scope.py | 88.51% <100.00%> (+0.30%) |
:arrow_up: |
| sentry_sdk/integrations/launchdarkly.py | 91.17% <91.17%> (ø) |
|
| sentry_sdk/flag_utils.py | 82.60% <82.60%> (ø) |
|
| sentry_sdk/integrations/openfeature.py | 84.00% <84.00%> (ø) |
Hey @cmanallen ! This is the best PR I have received ever! Great work.
The integrations should not change the Scope.
I have created an commit on your branch to illustrate how the flags could live on the integration rather than the scope (I hope you don't mind): https://github.com/getsentry/sentry-python/pull/3648/commits/430387fbbdc996328cce0f177fc537df88534ced
This way all the functionality is contained in the integration. I also added some tests to show how you can now set the capacity of the buffer when initializing the Integration.
wdyt?
Feel free to make changes to my commit if you want to do things differently.
@antonpirker Reverted your commit per our conversation on Slack. Tl;dr the commit didn't work because we need to be tied to the scope to maintain flag isolation. After @sl0thentr0py's comment about it being fine to keep the flags on the scope if this change is permanent I think its appropriate to revert that change.
Thanks @antonpirker and welcome back!