diff --git a/publish/sentry.php b/publish/sentry.php index ebd6082..8d4fedb 100644 --- a/publish/sentry.php +++ b/publish/sentry.php @@ -58,6 +58,7 @@ ], 'breadcrumbs' => [ + 'cache' => env('SENTRY_BREADCRUMBS_CACHE', true), 'sql_queries' => env('SENTRY_BREADCRUMBS_SQL_QUERIES', true), 'sql_bindings' => env('SENTRY_BREADCRUMBS_SQL_BINDINGS', true), 'sql_transaction' => env('SENTRY_BREADCRUMBS_SQL_TRANSACTION', true), diff --git a/src/Aspect/CacheAspect.php b/src/Aspect/CacheAspect.php new file mode 100644 index 0000000..4b988cb --- /dev/null +++ b/src/Aspect/CacheAspect.php @@ -0,0 +1,62 @@ +process(), function ($result) use ($proceedingJoinPoint, $startTime) { + if (! $this->switcher->isBreadcrumbEnable('cache')) { + return; + } + $arguments = $proceedingJoinPoint->arguments['keys']; + $method = sprintf('%s::%s()', $proceedingJoinPoint->className, $proceedingJoinPoint->methodName); + + $data['result'] = $result; + $data['arguments'] = $arguments; + $data['timeMs'] = (microtime(true) - $startTime) * 1000; + + Integration::addBreadcrumb(new Breadcrumb( + Breadcrumb::LEVEL_INFO, + Breadcrumb::TYPE_DEFAULT, + 'cache', + $method, + $data + )); + }); + } +} diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index 2e7fa97..82fcbda 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -20,6 +20,7 @@ public function __invoke(): array return [ 'aspects' => [ Aspect\BreadcrumbAspect::class, + Aspect\CacheAspect::class, Aspect\CoroutineAspect::class, Aspect\CrontabExecutorAspect::class, Aspect\GuzzleHttpClientAspect::class,