-
Notifications
You must be signed in to change notification settings - Fork 22
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
Upgrade Sentry to sentry-php 4 #90
base: master
Are you sure you want to change the base?
Conversation
Firesphere
commented
Nov 22, 2023
- Looking at also including SQL tracing
Thanks for this. The last time I bumped the SDK version, Sentry had refactored their API which took me ages to refactor for this module. How much testing have you done with this change in place? FYI there are x2 ways for the module to send a payload to sentry each of which uses a slightly different part of the Sentry API:
|
The SDK from sentry ( |
here is a quick snippet from one of my projects using the sdk v4
Sentry\init([
'dsn' => $sentryDSN,
'environment' => Director::get_environment_type(),
'attach_stacktrace' => true,
'logger' => Director::isDev() ? new \Sentry\Logger\DebugFileLogger(filePath: Director::baseFolder() . '/sentry.log') : null,
'http_ssl_verify_peer' => ini_get('curl.cainfo') ? true : false, // without this, it fails to send request on local
'before_send' => function (\Sentry\Event $event, ?\Sentry\EventHint $hint): \Sentry\Event {
if ($hint !== null && $hint->exception !== null && str_contains($hint->exception->getMessage(), 'database unavailable')) {
$event->setFingerprint(['database-unavailable']);
}
// Filter stacktrace
$st = $event->getStacktrace();
if ($st) {
$removed = 0;
foreach ($st->getFrames() as $idx => $frame) {
if (str_starts_with($frame->getFunctionName() ?? "", 'Sentry')) {
$st->removeFrame($idx - $removed);
$removed++;
}
}
$event->setStacktrace($st);
}
return $event;
},
]); |