Skip to content
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

use Symfony HttpClient as client #290

Closed
wants to merge 4 commits into from

Conversation

garak
Copy link
Contributor

@garak garak commented Dec 30, 2019

This should solve issue #246

Copy link
Contributor

@Jean85 Jean85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but I can't approve this; as the CI shows, this would break support for Symfony < 4.3, so it's a no-go at this level, it should be done by the end user. When we will drop 3.4 we could do this.

@garak
Copy link
Contributor Author

garak commented Jan 3, 2020

CI is wrong, HttpClient is fine with Symfony 3.4 too.
I'll change travis configuration to avoid failing

@garak garak force-pushed the symfony-http-client branch from a80e037 to 8b82268 Compare January 3, 2020 12:05
@Jean85
Copy link
Contributor

Jean85 commented Jan 3, 2020

No, it won't work with any project that requires symfony/symfony with a lower version.

Also, you're forcing this choice on the end user, cutting him off from the possibility to replace the client, or at least without the possibility of dropping that dependency.

@garak
Copy link
Contributor Author

garak commented Jan 3, 2020

I can't see any conflict between symfony/http-client and symfony/symfony.
About forcing the choice, you already did that when you required sdk. As mentioned in related issue, I'm for allowing the broader choice and not forcing user to any implementation, but it looks like "simplicity" is more important than choice

@Jean85
Copy link
Contributor

Jean85 commented Jan 3, 2020

You're right, symfony/symfony will not conflict as it is. But we're still missing the necessary package to inject the client in the HTTPlug discovery process, right?

@garak
Copy link
Contributor Author

garak commented Jan 3, 2020

Latest version of php-http/discovery is able to discover it
(BTW, failing tests in travis look unrelated)

@Jean85
Copy link
Contributor

Jean85 commented Jan 3, 2020

Latest version of php-http/discovery is able to discover it

Then you should lock against it (^1.7 seems to be the right version)

@Jean85
Copy link
Contributor

Jean85 commented Jan 3, 2020

I fear that CI failures are not unrelated... It's halting on Symfony Request signature, which is NOT coming from 3.4, but 4.4:

https://travis-ci.org/getsentry/sentry-symfony/jobs/632285363#L776

  • Downgrading symfony/http-foundation (v4.4.2 => v4.4.0): Loading from cache

@garak
Copy link
Contributor Author

garak commented Jan 3, 2020

Can you try to run tests on a local environment? On mine, all tests are green 🤔

@garak
Copy link
Contributor Author

garak commented Jan 13, 2020

I see "changes requested" but without any note. Is there something left to do?

Copy link
Contributor

@Jean85 Jean85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't like this change very much. You're forcing an opinionated client on the users, without a way to opt out. With sentry/sdk instead you can always replace that, and avoid installing the suggested package.

@garak
Copy link
Contributor Author

garak commented Jan 14, 2020

But you can replace this client too, I can't see any difference. The only difference is that this client is a Symfony component, so it's likely already required in a Symfony project.

@Jean85
Copy link
Contributor

Jean85 commented Jan 14, 2020

No, you can't replace it as a dependency, in this way it will be always installed, you can only leave it unused; that is a problem if it creates a conflict with a third package, for example.

And, since Flex, you can no longer give that for granted as installed.

@garak
Copy link
Contributor Author

garak commented Jan 14, 2020

I don't get you, what is the reason that keeps you from replacing?

@Jean85
Copy link
Contributor

Jean85 commented Jan 14, 2020

With sentry/sdk you have a meta package that you can replace in your composer.json to avoid installing the suggested transport altogether; with your approach, you do not have that meta package to replace anymore.

@garak
Copy link
Contributor Author

garak commented Jan 15, 2020

And can't you just replace symfony/http-client in the same way?

@Jean85
Copy link
Contributor

Jean85 commented Jan 15, 2020

Technically you would be lying, because you would be telling to Composer that you have something that works like symfony/http-client, but you actually don't. You could break future installation of other packages that would rely on that client.

@garak
Copy link
Contributor Author

garak commented Jan 15, 2020

Technically you would be lying, because you would be telling to Composer that you have something that works like symfony/http-client, but you actually don't. You could break future installation of other packages that would rely on that client.

But that exactly what you're doing by replacing anything.
If you're replacing, it's because you expressly don't want to install that package. If you actually need that package, you can just avoid replacing it.

But, again, since we're in a Symfony bundle, I don't see a reason to exclude a Symfony component, that you'll likely need for something else, since you're using Symfony after all.
Such likelihood is greater than the likelihood of Guzzle need.

So, in the end, if you want to force an implementation, at least force a Symfony one (given that not forcing anything would be always the best option)

@tristanbes
Copy link

I'm also in favor of taking advantage of a Symfony component if we must choose between Symfony HTTP client vs Guzzle :)

@Jean85
Copy link
Contributor

Jean85 commented Jan 16, 2020

But that exactly what you're doing by replacing anything.
If you're replacing, it's because you expressly don't want to install that package. If you actually need that package, you can just avoid replacing it.

That's only half of what you do with replace; if you use it, Composer do not install it, but believes that the code that it is able to autoload (src or vendor) is enough to satisfy the same requirement. So, if you try to install another package that requires the Symfony HTTP Client, it will happily install, only to fatal at runtime later. This is not advisable, since we would break stuff for our users in a dangerous and undetectable way.

Instead, sentry/sdk does not install any code by itself, it's just a metapackage, so if you require sentry/sentry directly alongside other packages that provide the HTTP transport as a replacement, you're not breaking anything for you nor other users.

@garak
Copy link
Contributor Author

garak commented Jan 17, 2020

So I guess that Sentry organisation should offer other meta packages, one for each possible client.
Or, at least, one for Symfony client.
Do you think it's feasible?

@Jean85
Copy link
Contributor

Jean85 commented Jan 17, 2020

Sentry offers an opinionated metapackage, creating others is not so useful and complicates maintenance; you can do it yourself, with another metapackage that replaces the original one and suggests the Symfony client.

@garak
Copy link
Contributor Author

garak commented Jan 17, 2020

Of course I could do that way, but then I'm afraid that it would be hard to get accepted as a replacement, being in a situation of "official vs unofficial"

@dvdoug
Copy link

dvdoug commented Jan 20, 2020

@Jean85 on the subject of putting "replace": {"sentry/sdk": "*"} into composer.json for those of us who prefer not to use Guzzle (that bit isn't documented btw, only the ability to additionally install the HTTP client of our choice), are there any guarantees from Sentry that in the future additional required packages or source code won't be added into sentry/sdk?

Using composer's replace mechanism for this does feel kinda hacky to me, but my main concern is that usually bumped versions of a package's own dependencies aren't included in the definition of semver compatibility so * feels unsafe, but limiting the replacement to ^2.0 of SDK would mean applications are in effect being required to chase the internal deps of the Symfony bundle if they don't want Guzzle installed?

[edited initial message]

@Jean85
Copy link
Contributor

Jean85 commented Jan 21, 2020

@dvdoug that is a fair question. I'll have to investigate that issue.

@Jean85
Copy link
Contributor

Jean85 commented Mar 23, 2020

Closing as solved by #327

@garak garak closed this Mar 23, 2020
@Jean85 Jean85 closed this Mar 23, 2020
@garak garak deleted the symfony-http-client branch March 23, 2020 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants