Search code examples
phpguzzlesentry

Sentry Transport errors


I'm trying to implement Sentry in our application.

I've used sentry/sdk but got some errors (probably due to some PHP settings), so I'm now trying to switch the transport method.

I removed sentry/sdk from my composer.json file and replaced it with sentry/sentry and php-http/guzzle7-adapter. Please note that in the documentation, they use the guzzle6-adapter, but that gave dependency errors (I was already using "guzzlehttp/guzzle": "^7.3", so I need to use version 7).

When now trying to initialize Sentry, I get the following error:

Fatal error: Uncaught Http\Discovery\Exception\DiscoveryFailedException: Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors - Puli Factory is not available - No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: . - No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates: Phalcon\Http\Message\StreamFactory, Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\StreamFactory, GuzzleHttp\Psr7\HttpFactory, Http\Factory\Diactoros\StreamFactory, Http\Factory\Guzzle\StreamFactory, Http\Factory\Slim\StreamFactory, Laminas\Diactoros\StreamFactory, Slim\Psr7\Factory\StreamFactory. in vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41

It is a custom application, so I cannot use e.g. the Sentry Laravel package.


Solution

  • The docs are incorrect at the moment and reference the old dependencies required.

    In case that you want to use Guzzle the following should work:

    composer require sentry/sentry guzzlehttp/guzzle http-interop/http-factory-guzzle
    

    This recreates the current SDK metapackage dependencies:

        "require": {
            "sentry/sentry": "^3.1",
            "http-interop/http-factory-guzzle": "^1.0",
            "symfony/http-client": "^4.3|^5.0"
        },
    

    Except that symfony/http-client was replaced by guzzlehttp/guzzle.