-
Notifications
You must be signed in to change notification settings - Fork 174
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
Fix decoration of symfony scoped http clients #704
Fix decoration of symfony scoped http clients #704
Conversation
Actually, it does it this way because Symfony does the exact same thing here. Either we're missing something, or it seems strange |
Yeah, I know this had to be the source. First of all I am by far no decoration expert and just learned a lot of the container building in the last weeks. |
Would you mind checking if you see the same behavior you’re reporting for the |
@ste93cry do you mean if the |
Another general problem you'll face when decorating every tagged client and being placed in front of the |
I am surprised this and more importantly the underlying bug is still open. IMO the current state of the http client Talking of this specific PR Iam relatively confident it does its job well but it needs some tests/confirmation. I do not wait for it tho, because we decided to disable the tracing. At least for now. |
I tested the changes and I'm still having issues. Symfony |
Can you tell the kind of problems? |
Wasted enough energy trying to convince it is a problem necessary to fix and this likely the correct solution. |
I'm sorry that you feel like you've wasted energy, the reported issue is clearly a bug and noone doubts that needs to be addressed. Unfortunately, this package is managed by a couple of volunteers and we often don't have all the time and resources to respond as quickly as expected. Regarding the issues that I have with your solution, I've observed that the decoration is not applied in all cases, depending on the configuration you have. Assuming a config like the one below, the http_client:
default_options:
retry_failed: true
scoped_clients:
noretry.client:
retry_failed: false
base_uri: https://example.com/
example.client:
retry_failed: true
base_uri: https://example.com/ With older versions of the frameworks, I've observed even worse scenarios, e.g. other decorators disappearing from the chain. This is not to say that the proposed solution is the wrong way, but it needs a lot more work to be reliable, apparently. |
@ste93cry this is indeed an issue that can be fixed by increasing the decoration priority to let's say 15. It needs to exceed the RetryableHttpClient which has priority 10. |
Unfortunately, I tried to change the priority and it still didn't fix the issue, in particular on versions of the framework prior to |
I tested the fix just an hour ago on Symfony 4 and 5 with and without retryable and on 5.4 with multiple decorations. |
I tried again, and I confirm what I already mentioned: Symfony
Symfony
|
@ste93cry I cannot follow all points, but I now first tested it in Symfony 6.3. The I didn't want to try to find a way around it directly or file a Symfony bug. Instead I pushed a new commit to my branch which fixes the decoration for Symfony 6.3 by using the Regarding mock_response_factory I did not test this. It probably is working in Symfony 6.3 now because of the transport service introduction. Not sure about earlier versions. I see no value in expecting the decoration there or is the http-client feature completely broken? |
This is indeed a part of the fix that we need. Since
It should be enough to just check that the
I tested it using the
We should get things right for all cases, otherwise, depending on which option you configured, you would see different behaviours which are hard to track and understand. I'm working on an improved solution, it seems to work but I need to polish it and find a meaningful way to test it. |
You can try but as far as I saw the definitions are not there at this point and even they would I don't know how safe it is to rely on it.
The |
Since you pushed new commits after closing this PR, I cannot reopen it, hence I've submitted my solution in a new one. I tested it on all versions of the framework we support, both in development and production mode, with both the retryable and the mock client enabled/disabled. It seems to work fine, but if you could make some more tests on your own it would be great! |
This MR Fixes #700 and resolves #701
I had a look how this bundle decorates the http-client. It iterates over all tagged http client services and creates new decorated services of them.
This is not the intended decoration way and(see update 1) should also not be necessary (?).Instead just the default http_client needs to be decorated which is put into all other (scoped) services.
This changes the
Sentry\SentryBundle\Tracing\HttpClient\TraceableHttpClient
not to be the first service in the decoration chain anymore, but this is hopefully not important.Note:
I did not test the function of sentries
TraceableHttpClient
before or after my change, I just tested the decoration chain to be intact for the default http client or when used as a scoped service.I tested it in Symfony 6.2 and can test this next week also in Symfony 5.4 which has no bigger internal changed behavior in this regard tho.
Update 1:
Removed the comment ragarding suggested way to decorate all different http client services because there actually ia none.