Skip to content

Ship the SDK with its own HTTP client instead of relying on HTTPlug  #1384

Closed

Description

@cleptric

Problem Statement

We're currently using Httplug to allow people to use their HTTP client of choice with the SDK.
This creates confusion about why we offer two composer packages sentry/sentry vs sentry/sdk.
I also have the feeling that this is rarely used and slightly over-optimized.

Solution Brainstorm

Two good examples of other SDKs/libraries shipping with an HTTP client are the AWS PHP SDK (they use Guzzle) and Stripe (they implemented their own client).

While I do not think that Guzzle is necessary in our case, what other HTTP clients we could look into using in our SDK?

Activity

  1. added this to the 4.0 milestone on Sep 29, 2022
  2. self-assigned this
    on Sep 29, 2022
  3. changed the title [-]Ship the SDK with it's own HTTP client instead of relying on HTTPlug [/-] [+]Ship the SDK with its own HTTP client instead of relying on HTTPlug [/+] on Sep 29, 2022
  4. stayallive commented on Sep 29, 2022

    @stayallive
    Collaborator

    I would vote to go for a very simple interface like the one Stripe uses.

    https://github.com/stripe/stripe-php/tree/master/lib/HttpClient

    They use a very simple interface so the user can implement their own and ship with a cURL client by default. The cURL extension is by and large a default and available almost always and has no composer dependencies.

    If we would go that route it's trivial to implement a Guzzle or whatever implementation that can be given to the SDK to do it's HTTP work without needing the full plumbing Htttplug provides which we workaround quite a lot already for timeouts and proxy configurations for example. Frameworks like Laravel and Symfony could also by default replace the client with the default shipped by their framework with a simple client implementation.

  5. ste93cry commented on Sep 29, 2022

    @ste93cry
    Contributor

    I would love to see Httplug go as it is a relic of the past when a PSR standard wasn't available for HTTP clients. However, I don't see the point in implementing our client interfaces: the code is already decoupled from any HTTP client, and you can already use whatever lib you want. Moreover, if we want to to provide an HTTP client out the box, we should just choose one (I would recommend symfony/http-client given that we already use other components from that framework) and certainly not reimplement one (it was like that in the past, and it didn't work well)

  6. cleptric commented on Sep 29, 2022

    @cleptric
    MemberAuthor

    What is Symfony's statement on how long they will support v5.0 of their HTTP client library?
    Their current v6.0 major already requires PHP 8.1 and up.

  7. Jean85 commented on Sep 29, 2022

    @Jean85
    Contributor

    Symfony has its how LTS schedule, so that's not a problem: https://symfony.com/releases#symfony-releases-calendar

    IMHO we should still rely on PSR-18 as a decoupling interface to allow everyone to either use the provided client or swap-it-out with another custom one. This should give us the best of both worlds, because we can rely on any common HTTP client in PHP (even the Symfony one) to implement that one.

  8. cleptric commented on Sep 30, 2022

    @cleptric
    MemberAuthor

    Using/building something PRS 18 compatible is definitely a good idea.
    I just want to iterate that we should ship some HTTP client by default, and let people use something else if they really want to, or, use the one that ships with Symfony/Laravel for our other SDKs.

    @stayallive Is the Laravel HTTP client PSR 18 compatible?

    Maybe @richardm-stripe or @dcr-stripe are open about telling us about the reasoning behind Stripe opting into implementing their own HTTP client in their SDK 🙏

  9. locked and limited conversation to collaborators on Oct 20, 2022
  10. converted this issue into a discussion #1411 on Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions