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

Added exception monitoring client #243

Merged
merged 67 commits into from
Jan 11, 2022
Merged

Conversation

asgrim
Copy link
Collaborator

@asgrim asgrim commented Oct 28, 2021

Dependencies on HTTP client

This adds a dependency on php-http/discovery. For this to work, you would already need an HTTP client installed, or install a compatible client.

If you receive an error, such as:

In ScoutErrorHandling.php line 66:
                                                         
  Class "Http\Discovery\Psr18ClientDiscovery" not found  

You need to resolve the HTTP discovery dependency, because your installed packages do not satisfy the requirement.

For example, if you are on PHP 7.1 and need Guzzle 6, composer require php-http/guzzle6-adapter nyholm/psr7 will fulfill the dependencies.

On PHP 7.2+, composer require guzzlehttp/guzzle:^7.0 is already compatible.

Configuration

By default, error reporting is not enabled at the moment. To enable, you should add errors_enabled configuration with a boolean true:

SCOUT_ERRORS_ENABLED=true

Laravel 5/6/7

In order to capture errors, in your \App\Exceptions\Handler::report function in your application:

    /**
     * Report or log an exception.
     *
     * @param  \Exception  $exception
     * @return void
     */
    public function report(Exception $exception)
    {
        $this->container->make(\Scoutapm\ScoutApmAgent::class)->recordThrowable($exception); // <-- add this line
        parent::report($exception);
    }

Laravel 8

In order to capture errors, in your \App\Exceptions\Handler::register function in your application:

    /**
     * Register the exception handling callbacks for the application.
     *
     * @return void
     */
    public function register()
    {
        $this->reportable(function (Throwable $e) {
            $this->container->make(ScoutApmAgent::class)->recordThrowable($e);
        });
    }

Lumen

In order to capture errors, in your \App\Exceptions\Handler::report function in your application:

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Throwable  $exception
     * @return void
     *
     * @throws \Exception
     */
    public function report(Throwable $exception)
    {
        app(\Scoutapm\ScoutApmAgent::class)->recordThrowable($exception);
        parent::report($exception);
    }

Symfony

Exception listening is provided out the box, so no additional code is needed for Symfony. However, since Symfony already has an HTTP Client out the box, you would need to install something like composer require php-http/httplug nyholm/psr7 to enable the PSR-18 HTTP Client auto discovery to use it.

@asgrim asgrim added enhancement New feature or request BC BREAK This PR contains a BC break; major version should be incremented labels Oct 28, 2021
@asgrim asgrim self-assigned this Oct 28, 2021
@asgrim asgrim added this to the 7.0.0 milestone Oct 28, 2021
@asgrim asgrim force-pushed the exception-monitoring-client branch 9 times, most recently from fea537e to 7cdbea7 Compare October 29, 2021 12:31
@asgrim asgrim force-pushed the exception-monitoring-client branch 7 times, most recently from c073c9c to d9a025b Compare November 11, 2021 15:48
@asgrim asgrim force-pushed the exception-monitoring-client branch 7 times, most recently from a89acb3 to 676fd85 Compare November 23, 2021 11:59
@asgrim asgrim marked this pull request as ready for review November 23, 2021 12:35
@asgrim asgrim requested a review from dlanderson November 24, 2021 08:03
asgrim added 23 commits January 11, 2022 09:47

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
…rning if error_reporting=true and an HTTP client is not found.
…UriReportingConfiguration supports positive-int|0
@asgrim asgrim force-pushed the exception-monitoring-client branch from 270e076 to 000bdce Compare January 11, 2022 09:55
@asgrim
Copy link
Collaborator Author

asgrim commented Jan 11, 2022

BC failures are expected; preparing for 7.0.0 release.

@asgrim asgrim merged commit 7b024b3 into master Jan 11, 2022
@asgrim asgrim deleted the exception-monitoring-client branch January 11, 2022 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC BREAK This PR contains a BC break; major version should be incremented enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants