KEMBAR78
# Set Up Profiling | Sentry for Laravel Profiling for PHP is supported with Sentry Laravel SDK version `3.3.0` and above. With [Profiling](https://docs.sentry.io/product/explore/profiling.md), Sentry allows you to collect and analyze performance profiles from real users in production to give you a complete picture of how your application performs in a variety of environments. Under the hood, we're using Wikipedia's sampling profiler [Excimer](https://github.com/wikimedia/mediawiki-php-excimer). The Excimer PHP extension supports PHP 7.2 and up. Excimer requires Linux or macOS and doesn't support Windows. ## [Installation](https://docs.sentry.io/platforms/php/guides/laravel/profiling.md#installation) Here's how to install Excimer with a Linux package manager, PECL, or build from a source. ### [Linux Package Manager](https://docs.sentry.io/platforms/php/guides/laravel/profiling.md#linux-package-manager) ```bash apt-get install php-excimer ``` See for additional distributions. ### [PECL](https://docs.sentry.io/platforms/php/guides/laravel/profiling.md#pecl) ```bash pecl install excimer ``` See for more information. ### [Build From Source](https://docs.sentry.io/platforms/php/guides/laravel/profiling.md#build-from-source) ```bash git clone https://github.com/wikimedia/mediawiki-php-excimer.git cd excimer/ phpize && ./configure && make && sudo make install ``` Depending on your environment, you may need to enable the Excimer extension afterwards. ```bash phpenmod -s fpm excimer # or phpenmod -s apache2 excimer ``` ## [Enable Tracing](https://docs.sentry.io/platforms/php/guides/laravel/profiling.md#enable-tracing) Sentry's tracing product has to be enabled in order for Profiling to work. Check out the [performance setup](https://docs.sentry.io/platforms/php/guides/laravel/tracing.md) documentation for more detailed information. `config/sentry.php` ```php 'traces_sample_rate' => 1.0, ``` ## [Enable Profiling](https://docs.sentry.io/platforms/php/guides/laravel/profiling.md#enable-profiling) `config/sentry.php` ```php 'traces_sample_rate' => 1.0, // Set a sampling rate for profiling - this is relative to traces_sample_rate 'profiles_sample_rate' => 1.0, ``` ## [Improve Response Time](https://docs.sentry.io/platforms/php/guides/laravel/profiling.md#improve-response-time) Response time is somewhat impacted when you use the performance capabilities in your Laravel application, (depending on the `traces_sample_rate` you've configured). If your web server is using FastCGI, our SDK utilizes a [`terminable middleware`](https://laravel.com/docs/10.x/middleware#terminable-middleware), which means that the response is sent to the user before the profiling data is sent to Sentry. If your web server isn't using FastCGI, you can run [Relay](https://docs.sentry.io/product/relay/getting-started.md) locally on the same machine or a local network that can act as a proxy/agent. Doing this will make the PHP process send requests to your local Relay, which will then forward them to Sentry, instead of sending requests to Sentry directly. To begin using Relay, check out our docs for [getting started](https://docs.sentry.io/product/relay/getting-started.md). We recommend using Relay in `managed` mode (which is the default). Follow the instructions in the Relay docs to send a test event through Relay to Sentry. Don't forget to update your `DSN` to point to your running Relay instance. After you've set up Relay, you should see a dramatic improvement in how much your server is impacted.