Skip to content

Commit

Permalink
implement profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
rommelfreddy committed Aug 7, 2024
1 parent b401496 commit f8eac4e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Data extends AbstractHelper
'tracing_sample_rate',
'performance_tracking_enabled',
'performance_tracking_excluded_areas',
'profiles_sample_rate',
'ignore_js_errors',
];

Expand Down Expand Up @@ -95,6 +96,11 @@ public function getTracingSampleRate(): float
return (float) $this->config['tracing_sample_rate'] ?? 0.2;
}

public function getPhpProfileSampleRate(): float
{
return (float) ($this->config['profiles_sample_rate'] ?? 0);
}

/**
* @return array|null
*/
Expand Down
4 changes: 4 additions & 0 deletions Plugin/GlobalExceptionCatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public function aroundLaunch(AppInterface $subject, callable $proceed)
$config->setTracesSampleRate($this->sentryHelper->getTracingSampleRate());
}

if ($rate = $this->sentryHelper->getPhpProfileSampleRate()) {
$config->setData('profiles_sample_rate', $rate);
}

$this->eventManager->dispatch('sentry_before_init', [
'config' => $config,
]);
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This module uses the [Magento Deployment Configuration](https://devdocs.magento.
'tracing_sample_rate' => 0.5,
'performance_tracking_enabled' => true,
'performance_tracking_excluded_areas' => ['adminhtml', 'crontab'],
'profiles_sample_rate' => 0.5,
'ignore_js_errors' => []
]
```
Expand All @@ -46,6 +47,7 @@ Next to that there are some configuration options under Stores > Configuration >
* `tracing_sample_rate` if tracing is enabled, you should also set the sample rate. Default: `0.2`
* `performance_tracking_enabled` if performance tracking is enabled, a performance report got generated for the request. Default: `false`
* `performance_tracking_excluded_areas`: if `performance_tracking_enabled` is enabled, we recommend to exclude the `adminhtml` & `crontab` area. Default `['adminhtml', 'crontab']`
* `profiles_sample_rate` if this option is larger than 0 (zero), the module will create a profile of the request. Please note that you have to install [Excimer](https://www.mediawiki.org/wiki/Excimer) on your server to use profiling. [Sentry documentation](https://docs.sentry.io/platforms/php/profiling/). You have to enable tracing too. Default `0` (disabled)
* `ignore_js_errors` array of javascript error messages, which should be not send to Sentry. (see also `ignoreErrors` in [Sentry documentation](https://docs.sentry.io/clients/javascript/config/))

### Configuration for Adobe Cloud
Expand All @@ -70,6 +72,8 @@ using the "Variables" in Adobe Commerce using the following variables:
The following configuration settings can be overridden in the Magento admin. This is limited to ensure that changes to
particular config settings can only be done on server level and can't be broken by changes in the admin.

Please note, that it is not possible to use profiling within the Adobe Cloud.

## Optional error page configuration
- Optional you can configure custom error pages in pub/errors. You can use the sentry feedback form and insert here the sentry log ID. The Sentry Log Id is captured in de customer session and can be retrieved in `processor.php`.

Expand Down

0 comments on commit f8eac4e

Please sign in to comment.