-
-
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
Extract the code to create a transport from the client builder to a transport factory #855
Extract the code to create a transport from the client builder to a transport factory #855
Conversation
This should be merged only if getsentry/sentry-php#855 is merged.
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 clean. Thanks! I do agree with @Jean85 but after that LGTM!
493ba7f
to
49fe917
Compare
I don’t like to expose such method from the builder as it seems we’re leaking some internal behavior of the builder. I didn’t investigate if it’s possible, but we should probably instead wrap the HTTP client internally |
@ste93cry I can see your point but in that case the documentation to register custom transport should have all the boilerplate to basically reproduce the |
The problem arises because if someone sets the transport then we don't wrap the HTTP client because the transport may not need it and so doing it would be useless sentry-php/src/ClientBuilder.php Lines 309 to 313 in 98a07e7
What I was suggesting was to always wrap the client regardless of the transport set. A clearer solution imo would be to have a |
@ste93cry thanks for the feedback. I'll try to update my pull request over the week end. |
@ste93cry may I ask for your opinion? This is not the complete thing, I still need to write the tests but before that I would like you to acknowledge if the solution looks good enough for you. Regarding the |
411c4a9
to
fd43309
Compare
I think that the direction may be good. Probably it makes sense to passo to the |
@ste93cry let me know if it looks like something that could be merged or if I need to work on it a little bit more. |
I did some changes to your PR, may I ask if I can push them to your branch? In that case please ensure that maintainers can edit your PR by checking the checkbox in the right sidebar |
@ste93cry the checkbox is ticked so you should be able to push. Thanks! |
92ce087
to
b3f36c5
Compare
I pushed the changes and there is still a lot of work that must be done, from documentation to unit tests, but this should be a good start to provide the flexibility you were looking for at the beginning of this PR to create a custom HTTP client without having to also think about the plugins needed to make it work. I didn't have the chance to try it with a real Sentry server yet, so it may be that everything doesn't work anymore. It's just a starting point, please let me know if you're ok with them and then we can interate over this if you agree and see what cames out. The only downside to all of these changes is that we are polluting the codebase with deprecated things and the complexity is increasing rapidly and this makes me wonder if this is a good way to solve the issue |
@ste93cry Thanks, I see you went all the way to create a dedicated factory for the Yes, it is covering my original use case 👍 I'll try it out with real server tomorrow at work. Given that we moved code around, I think it should work. In my opinion, it looks good and add some modularity and good extension points. Do you want me to fix the broken tests and PHPStan? On the other hand what kind of test you had in mind for the |
This PR needs to be rebased but since it's scheduled for 2.3 and there are still things left to be merged it may be that it will need to be done again. We should also find a way to still support adding custom plugins to the HTTP client to not break BC. Since this is new code we should finally avoid using the deprecated |
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.
Still a few changes, mostly missing documentation and a rebase to start with. Also missing is the handling of the addHttpClientPlugin
and removeHttpClientPlugin
methods that should still work with the new approach based on factories to not break BC. It would be also good to rework all the tests to stop using assertAttribute
which is deprecated by PHPUnit
8026c2e
to
2b16b07
Compare
@ste93cry can you review and give us feedback? Regarding this:
I am fine with that but that would require to add getters only for testing, are you OK with that? |
8344ffa
to
8b78689
Compare
I reworked some of the newly added tests to not use the reflection to test internal state of the objects and I also created an additional HTTP client factory to support wrapping a client with the plugins. I decided to go that way because in |
fa91d2e
to
5a7624f
Compare
5a7624f
to
02777d4
Compare
02777d4
to
4afa495
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.
Thank you for your contribution, all changes seem fine so LGTM
This should ease the process of registering a custom transport.
Related to #787