-
Notifications
You must be signed in to change notification settings - Fork 517
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
ref(flags): register LD hook in setup instead of init, and don't check for initialization #3890
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #3890 +/- ##
==========================================
- Coverage 79.89% 79.88% -0.01%
==========================================
Files 139 139
Lines 15429 15429
Branches 2624 2623 -1
==========================================
- Hits 12327 12326 -1
- Misses 2228 2229 +1
Partials 874 874
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good.
@aliu39 This needs to be reverted. This is not the correct way to manage this behavior. Regardless, where is the documentation for this change? A notion doc or anything to describe why this is important? |
Reverted here: #3900. There are too many holes in this. How would a user track multiple clients? Multiple integrations? Does that work? There are no tests for it. Let's discuss on Monday. |
…n't chec…" (#3900) Mutating a class attribute on `__init__` violates encapsulation and will lead to strange errors. We need to rethink how we want to implement this before we merge any code. A simple reproduction of the issue: ```python >>> class X: ... y = 0 ... def __init__(self, z): ... self.__class__.y = z ... >>> a = X(1) >>> b = X(2) >>> X.y 2 >>> a.y 2 >>> b.y 2 ``` Reverts #3890 This reverts commit c3516db. Co-authored-by: Anton Pirker <[email protected]>
Refactors setup code and removes an error case from the LaunchDarkly integration
IMO we should only hook into LD once, when this integration is setup by
sentry_sdk.init
. It's rare, but this class could be instantiated more than once, from user error, tests, etc. It's reasonable to expect Sentryinit
is only called once in prod.We shouldn't fail if LDClient hasn't initialized yet. Initialization is the async process of connecting to the LD server, and may take a moment. With the setup code from our docs, we configure LD right before calling Sentry
init
, and don't wait for initialization to complete. This could lead to a lot of errors / failure to start your app if you have a slow internet connection. It's ultimately the user's responsibility to ensure LD is initialized before evaluating flags. Even if the client's never initialized, flags will default to False, so nothing's breaking on our end.