Profiling

With profiling, 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. The Excimer PHP extension does support PHP 7.2 and up, for PHP 8.2 support, make sure to use Excimer version 1.1.0.

Excimer requires Linux and does not support Windows or macOS.

Installation

Linux package manager

Copied
apt-get install php-excimer

See https://www.mediawiki.org/wiki/Excimer for additional distributions.

PECL

Copied
pecl install excimer

See https://pecl.php.net/package/excimer for more information.

Build from source

Copied
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.

Copied
phpenmod -s fpm excimer
# or
phpenmod -s apache2 excimer

Enable Performance Monitoring

Profiling depends on Sentry's performance monitoring product being enabled beforehand. Check out the performance setup and custom instrumentation documentation for more detailed information.

Copied
\Sentry\init([
    'dsn' => '__DSN__',
    'traces_sample_rate' => 1.0,
]);

Enabling Profiling

Copied
\Sentry\init([
    'dsn' => '__DSN__',
    'traces_sample_rate' => 1.0,
    // Set a sampling rate for profiling - this is relative to traces_sample_rate
    'profiles_sample_rate' => 1.0,
]);

Troubleshooting

If you don't see any profiling data in sentry.io, you can try the following:

  • Ensure that performance monitoring is enabled.
  • Ensure that the automatic instrumentation is sending performance data to Sentry by going to the Performance page in sentry.io.
  • If the automatic instrumentation is not sending performance data, try using custom instrumentation.
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").