-
-
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
Disable http plug discovery when using custom transport #741
Comments
I could be missing something, but looking at the source code if you want to use a custom HTTP client you can just set it using the $httpClient = new CustomHttpClient();
$clientBuilder = ClientBuilder::create(['dsn' => '__PUBLIC_DSN__']);
$clientBuilder->setHttpClient($httpClient);
// $client will use the default transport HttpTransport with the configured CustomHttpClient client
$client = $clientBuilder->getClient(); |
I'm not using http plug at all. It's a completely custom HTTP client with no integration of http plug. |
I still don't get how it's using the HttpClient from HTTPlug. If you set the transport yourself no call will be made to either the |
The issue is that there is no HttpClient from HTTPlug and thus an exception is thrown by By making the proposed changes, we don't make any unnecessary discoveries when they are not used at all. |
Got it now, I misunderstood your first message sorry. I see the problem now and agree with you we should not autodiscover anything if a custom transport is set, but probably I would think about if it really makes sense to expose the |
That does make sense. I'd also say that these three lines could be moved into sentry-php/src/ClientBuilder.php Lines 262 to 264 in 5ec1fbe
Since they're related to the used transport and a custom transport won't use them in any way. |
I'm using this SDK (the 2.0 beta version) inside an asynchronous ReactPHP application, but due to the broken http-plug reactphp client I've made my own sentry transport which uses the already available HTTP client inside my application. But due to the way how the client is built inside the client builder, even when I set a custom transport, the client builder tries to find a http plug HTTP client using the http plug discovery mechanism.
As such I have to set a custom strategy to mitigate this.
Would you be interested in a simple patch to not do the discovery if a transport is set? From what I've seen the HTTP client is only used when building a transport. So the patch would be to simply check whether a transport is set or not.
sentry-php/src/ClientBuilder.php
Lines 260 to 268 in 5ec1fbe
The simple patch would be to change
sentry-php/src/ClientBuilder.php
Lines 264 to 265 in 5ec1fbe
to
Of course you're welcome to do the simple change yourself. :)
The text was updated successfully, but these errors were encountered: