ref(flags): register LD hook in setup instead of init, and don't check for initialization#3890
Merged
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
|
Member
|
@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? |
Member
|
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. |
antonpirker
added a commit
that referenced
this pull request
Jan 7, 2025
…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 <anton.pirker@sentry.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 Sentryinitis 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.