-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
Deprecate the methods on the HubInterface to get and set the current hub #847
Conversation
174a397
to
0f8ace6
Compare
After looking at the implementation of several other SDKs I decided to follow the way of the .NET SDK and implement a singleton class with static methods only that will be the main entry point for all the SDK common features like capturing messages, errors, etc. To support getting the hub instance from a service container the users will need to register the instance of the |
38bf122
to
fbac5ef
Compare
f8882ad
to
62a48fa
Compare
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.
I don't fully understand the motivation of this change, it was fine before (aside from the two error integrations that were broken before).
It changes a lot of internal behaviour which is now inconsitent at times.
62a48fa
to
9ccffc4
Compare
The change originated because as reported by @B-Galati the singleton should be managed somewhere else: it's not up to the implementors of the
Indeed I didn't account for some things, I reverted the changes and I will address the found bugs not strictly related to this change in a separate PR so that we can ship the fix as soon as possible |
b909d91
to
0562432
Compare
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.
I don't like to have the deprecation warnings thrown around. As soon as we release this all Laravel, Symfony and people that have just ^2.0
in their composer.json will be bombarded with ErrorException
s from their error tracking library. This to me is unacceptable. I would suggest to remove those in favor of @deprecated
docs so we can prevent that from happening.
This is part of how deprecation works, even in PHP... If you use something that is deprecated then unless you suppress the errors you will get warnings and this is good because you may not even notice a docblock that marks a function as deprecated. Even frameworks and other libraries out of here throws such warnings and we did the same in the past. This PR should not throw any deprecation as far as I coded it right , but if someone used deprecated functions then he will get them. |
@HazAT are you more willing to approve this PR if I don't deprecate the global functions? Even though I strongly disagree because we have duplicate ways to do the same things in this case users would still be able to use the same API as now as the change would be transparent for them, apart from EDIT
EDIT 2 |
1be5f15
to
c9042fe
Compare
c9042fe
to
8afbf0f
Compare
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.
We had a lot of back and forth on this topic, most of the stuff we discussed was "offline".
I am happy with the current implementation, it's sound and makes testing easier.
Some additional requirements:
- Changelog is missing
- I want also want an update in
sentry-laravel
(potentiallysentry-symfony
) to not use the deprecated functionsgetCurrentHub
/setCurrentHub
. The version of the core php package and updates to laravel/symfony should go at the same time.
@HazAT the update on |
@HazAT another question: the two integrations will need a bump but they rely on |
80ce7d7
to
4411260
Compare
You could also just use |
I am for bumping/code change if possible. |
4411260
to
cab61e8
Compare
As discussed in #845, putting the
getCurrentHub
andsetCurrentHub
on theHubInterface
was an error.Based on what has been done in other SDKs (I used Python and JS as reference) I decided to deprecate them and move the handling of the current hub in aAny idea, comment or feedback is greatly appreciated.HubManager
class that can be used as a service in a proper DI-based environment or through the global functions for those that prefers to use them. PR is not ready yet, but I would like an opinion on a few implementation details. In particular, I'm undecided on how the global functiongetHubManager
should be written. The main thing I would like to support is the retrieval of the instance from a service container, so I had to pass a callback around that will be used as a sort of factory method to instantiate the singleton variable the first time it's accessed. Another thing I had to solve is that since we (especially in an application based on a framework) cannot be sure that the function won't be accessed before the service container is built and initialized I needed a way to force replacing the instance even if it was already set. I don't really like this because of all the bad things that could occur when replacing an instance when you shouldn't, but I couldn't came up with a better solution.