From f131cf1be10560c77be21223b5fb80da7e5fd091 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 08:53:51 +0800 Subject: [PATCH 01/10] feat(sentry): add filesystem operations tracking with FilesystemAspect - Add FilesystemAspect class to track Flysystem adapter operations - Add filesystem breadcrumbs and tracing configuration options - Register FilesystemAspect in ConfigProvider for AOP - Enable tracking of file operations like read, write, delete, move, copy - Supports configuration via SENTRY_BREADCRUMBS_FILESYSTEM and SENTRY_TRACING_SPANS_FILESYSTEM env vars --- src/sentry/publish/sentry.php | 2 + src/sentry/src/Aspect/FilesystemAspect.php | 70 ++++++++++++++++++++++ src/sentry/src/ConfigProvider.php | 1 + 3 files changed, 73 insertions(+) create mode 100644 src/sentry/src/Aspect/FilesystemAspect.php diff --git a/src/sentry/publish/sentry.php b/src/sentry/publish/sentry.php index a6069a138..e97ece50b 100644 --- a/src/sentry/publish/sentry.php +++ b/src/sentry/publish/sentry.php @@ -63,6 +63,7 @@ 'cache' => env('SENTRY_BREADCRUMBS_CACHE', true), 'command' => env('SENTRY_BREADCRUMBS_COMMAND', true), 'command_input' => env('SENTRY_BREADCRUMBS_COMMAND_INPUT', true), + 'filesystem' => env('SENTRY_BREADCRUMBS_FILESYSTEM', 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), @@ -106,6 +107,7 @@ 'coroutine' => env('SENTRY_TRACING_SPANS_COROUTINE', true), 'db' => env('SENTRY_TRACING_SPANS_DB', true), 'elasticsearch' => env('SENTRY_TRACING_SPANS_ELASTICSEARCH', true), + 'filesystem' => env('SENTRY_TRACING_SPANS_FILESYSTEM', true), 'guzzle' => env('SENTRY_TRACING_SPANS_GUZZLE', true), 'rpc' => env('SENTRY_TRACING_SPANS_RPC', true), 'grpc' => env('SENTRY_TRACING_SPANS_GRPC', true), diff --git a/src/sentry/src/Aspect/FilesystemAspect.php b/src/sentry/src/Aspect/FilesystemAspect.php new file mode 100644 index 000000000..45cc9f2f1 --- /dev/null +++ b/src/sentry/src/Aspect/FilesystemAspect.php @@ -0,0 +1,70 @@ +switcher->isBreadcrumbEnabled('filesystem')) { + return $proceedingJoinPoint->process(); + } + + $method = $proceedingJoinPoint->methodName; + // See https://develop.sentry.dev/sdk/performance/span-operations/#web-server + $op = "file.{$method}"; + $description = $proceedingJoinPoint->className . '::' . $method; + $data = []; + + Integration::addBreadcrumb(new Breadcrumb( + Breadcrumb::LEVEL_INFO, + Breadcrumb::TYPE_DEFAULT, + $op, + $description, + $data + )); + + return $proceedingJoinPoint->process(); + } +} diff --git a/src/sentry/src/ConfigProvider.php b/src/sentry/src/ConfigProvider.php index 6ca66ca3b..507b64cc0 100644 --- a/src/sentry/src/ConfigProvider.php +++ b/src/sentry/src/ConfigProvider.php @@ -22,6 +22,7 @@ public function __invoke(): array Aspect\BreadcrumbAspect::class, Aspect\CacheAspect::class, Aspect\CoroutineAspect::class, + Aspect\FilesystemAspect::class, Aspect\GuzzleHttpClientAspect::class, Aspect\LoggerAspect::class, Aspect\RedisAspect::class, From 7058af1547064d515fd5e245bdde2842a96b4032 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 09:19:10 +0800 Subject: [PATCH 02/10] refactor(sentry): reorganize filesystem methods and enhance breadcrumb data structure --- src/sentry/src/Aspect/FilesystemAspect.php | 73 ++++++++++++++++++---- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/src/sentry/src/Aspect/FilesystemAspect.php b/src/sentry/src/Aspect/FilesystemAspect.php index 45cc9f2f1..b03cd1904 100644 --- a/src/sentry/src/Aspect/FilesystemAspect.php +++ b/src/sentry/src/Aspect/FilesystemAspect.php @@ -20,24 +20,22 @@ class FilesystemAspect extends AbstractAspect { public $classes = [ + 'League\Flysystem\*\*Adapter::directoryExists', 'League\Flysystem\*\*Adapter::write', 'League\Flysystem\*\*Adapter::writeStream', - 'League\Flysystem\*\*Adapter::setVisibility', + 'League\Flysystem\*\*Adapter::read', + 'League\Flysystem\*\*Adapter::readStream', 'League\Flysystem\*\*Adapter::delete', 'League\Flysystem\*\*Adapter::deleteDirectory', 'League\Flysystem\*\*Adapter::createDirectory', - 'League\Flysystem\*\*Adapter::move', - 'League\Flysystem\*\*Adapter::copy', - 'League\Flysystem\*\*Adapter::fileExists', - 'League\Flysystem\*\*Adapter::directoryExists', - 'League\Flysystem\*\*Adapter::has', - 'League\Flysystem\*\*Adapter::read', - 'League\Flysystem\*\*Adapter::readStream', - 'League\Flysystem\*\*Adapter::listContents', + 'League\Flysystem\*\*Adapter::setVisibility', + 'League\Flysystem\*\*Adapter::visibility', + 'League\Flysystem\*\*Adapter::mimeType', 'League\Flysystem\*\*Adapter::lastModified', 'League\Flysystem\*\*Adapter::fileSize', - 'League\Flysystem\*\*Adapter::mimeType', - 'League\Flysystem\*\*Adapter::visibility', + 'League\Flysystem\*\*Adapter::listContents', + 'League\Flysystem\*\*Adapter::move', + 'League\Flysystem\*\*Adapter::copy', ]; public function __construct( @@ -52,10 +50,59 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint) } $method = $proceedingJoinPoint->methodName; + $arguments = $proceedingJoinPoint->arguments['keys'] ?? []; // See https://develop.sentry.dev/sdk/performance/span-operations/#web-server $op = "file.{$method}"; - $description = $proceedingJoinPoint->className . '::' . $method; - $data = []; + $description = match ($method) { + 'move', 'copy' => sprintf( + 'from "%s" to "%s"', + $arguments['source'] ?? '', + $arguments['destination'] ?? '' + ), + 'write', 'writeStream', + 'read', 'readStream', + 'setVisibility', 'visibility', + 'delete', 'deleteDirectory', 'createDirectory', + 'fileExists', 'directoryExists', + 'listContents', + 'lastModified', + 'fileSize', + 'mimeType', => $arguments['path'] ?? '', + default => '', + }; + $data = match ($method) { + 'move', 'copy' => [ + 'from' => $arguments['source'] ?? '', + 'to' => $arguments['destination'] ?? '', + ], + 'write', 'writeStream' => [ + 'path' => $arguments['path'] ?? '', + 'config' => $arguments['config'] ?? null, + ], + 'read', 'readStream' => [ + 'path' => $arguments['path'] ?? '', + ], + 'setVisibility' => [ + 'path' => $arguments['path'] ?? '', + 'visibility' => $arguments['visibility'] ?? '', + ], + 'visibility', + 'delete', 'deleteDirectory' => [ + 'path' => $arguments['path'] ?? '', + ], + 'createDirectory' => [ + 'path' => $arguments['path'] ?? '', + 'config' => $arguments['config'] ?? null, + ], + 'fileExists', 'directoryExists', + 'listContents', + 'lastModified', + 'fileSize', + 'mimeType' => [ + 'path' => $arguments['path'] ?? '', + ], + default => [], + }; Integration::addBreadcrumb(new Breadcrumb( Breadcrumb::LEVEL_INFO, From 745baf8b11078eb2a9032ca4433ea45715d01954 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 09:19:42 +0800 Subject: [PATCH 03/10] chore(sentry): add comment placeholder for additional adapter methods in FilesystemAspect --- src/sentry/src/Aspect/FilesystemAspect.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sentry/src/Aspect/FilesystemAspect.php b/src/sentry/src/Aspect/FilesystemAspect.php index b03cd1904..b1e3ebbbc 100644 --- a/src/sentry/src/Aspect/FilesystemAspect.php +++ b/src/sentry/src/Aspect/FilesystemAspect.php @@ -36,6 +36,8 @@ class FilesystemAspect extends AbstractAspect 'League\Flysystem\*\*Adapter::listContents', 'League\Flysystem\*\*Adapter::move', 'League\Flysystem\*\*Adapter::copy', + + // More adapter methods can be added here ]; public function __construct( From 86a21222e21ab5b6d861ed9f194546e70824c688 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 09:27:48 +0800 Subject: [PATCH 04/10] feat(sentry): add FilesystemAspect for tracking filesystem operations --- src/sentry/src/ConfigProvider.php | 1 + .../src/Tracing/Aspect/FilesystemAspect.php | 120 ++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/sentry/src/Tracing/Aspect/FilesystemAspect.php diff --git a/src/sentry/src/ConfigProvider.php b/src/sentry/src/ConfigProvider.php index 507b64cc0..0f9cbd1cd 100644 --- a/src/sentry/src/ConfigProvider.php +++ b/src/sentry/src/ConfigProvider.php @@ -34,6 +34,7 @@ public function __invoke(): array Tracing\Aspect\CoroutineAspect::class, Tracing\Aspect\DbAspect::class, Tracing\Aspect\ElasticsearchAspect::class, + Tracing\Aspect\FilesystemAspect::class, Tracing\Aspect\GrpcAspect::class, Tracing\Aspect\GuzzleHttpClientAspect::class, Tracing\Aspect\KafkaProducerAspect::class, diff --git a/src/sentry/src/Tracing/Aspect/FilesystemAspect.php b/src/sentry/src/Tracing/Aspect/FilesystemAspect.php new file mode 100644 index 000000000..1c620fcaa --- /dev/null +++ b/src/sentry/src/Tracing/Aspect/FilesystemAspect.php @@ -0,0 +1,120 @@ +switcher->isTracingEnabled('filesystem')) { + return $proceedingJoinPoint->process(); + } + + $method = $proceedingJoinPoint->methodName; + $arguments = $proceedingJoinPoint->arguments['keys'] ?? []; + // See https://develop.sentry.dev/sdk/performance/span-operations/#web-server + $op = "file.{$method}"; + $description = match ($method) { + 'move', 'copy' => sprintf( + 'from "%s" to "%s"', + $arguments['source'] ?? '', + $arguments['destination'] ?? '' + ), + 'write', 'writeStream', + 'read', 'readStream', + 'setVisibility', 'visibility', + 'delete', 'deleteDirectory', 'createDirectory', + 'fileExists', 'directoryExists', + 'listContents', + 'lastModified', + 'fileSize', + 'mimeType', => $arguments['path'] ?? '', + default => '', + }; + + $data = match ($method) { + 'move', 'copy' => [ + 'from' => $arguments['source'] ?? '', + 'to' => $arguments['destination'] ?? '', + ], + 'write', 'writeStream' => [ + 'path' => $arguments['path'] ?? '', + 'config' => $arguments['config'] ?? null, + ], + 'read', 'readStream' => [ + 'path' => $arguments['path'] ?? '', + ], + 'setVisibility' => [ + 'path' => $arguments['path'] ?? '', + 'visibility' => $arguments['visibility'] ?? '', + ], + 'visibility', + 'delete', 'deleteDirectory' => [ + 'path' => $arguments['path'] ?? '', + ], + 'createDirectory' => [ + 'path' => $arguments['path'] ?? '', + 'config' => $arguments['config'] ?? null, + ], + 'fileExists', 'directoryExists', + 'listContents', + 'lastModified', + 'fileSize', + 'mimeType' => [ + 'path' => $arguments['path'] ?? '', + ], + default => [], + }; + + return trace( + fn () => $proceedingJoinPoint->process(), + SpanContext::make() + ->setOp($op) + ->setData($data) + ->setOrigin('auto.filesystem') + ->setDescription($description) + ); + } +} From 06208441ab2e533c9c483a5f326b553427d9350e Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 09:33:06 +0800 Subject: [PATCH 05/10] refactor(sentry): simplify FilesystemAspect by extending base class and extracting metadata logic --- src/sentry/src/Aspect/FilesystemAspect.php | 28 ++++-- .../src/Tracing/Aspect/FilesystemAspect.php | 87 +------------------ 2 files changed, 22 insertions(+), 93 deletions(-) diff --git a/src/sentry/src/Aspect/FilesystemAspect.php b/src/sentry/src/Aspect/FilesystemAspect.php index b1e3ebbbc..cfcdfad08 100644 --- a/src/sentry/src/Aspect/FilesystemAspect.php +++ b/src/sentry/src/Aspect/FilesystemAspect.php @@ -51,6 +51,24 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint) return $proceedingJoinPoint->process(); } + [$op, $description, $data] = $this->getSentryMetadata($proceedingJoinPoint); + + Integration::addBreadcrumb(new Breadcrumb( + Breadcrumb::LEVEL_INFO, + Breadcrumb::TYPE_DEFAULT, + $op, + $description, + $data + )); + + return $proceedingJoinPoint->process(); + } + + /** + * @return array{0: string, 1: string, 2: array} [op, description, data] + */ + protected function getSentryMetadata(ProceedingJoinPoint $proceedingJoinPoint): array + { $method = $proceedingJoinPoint->methodName; $arguments = $proceedingJoinPoint->arguments['keys'] ?? []; // See https://develop.sentry.dev/sdk/performance/span-operations/#web-server @@ -106,14 +124,6 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint) default => [], }; - Integration::addBreadcrumb(new Breadcrumb( - Breadcrumb::LEVEL_INFO, - Breadcrumb::TYPE_DEFAULT, - $op, - $description, - $data - )); - - return $proceedingJoinPoint->process(); + return [$op, $description, $data]; } } diff --git a/src/sentry/src/Tracing/Aspect/FilesystemAspect.php b/src/sentry/src/Tracing/Aspect/FilesystemAspect.php index 1c620fcaa..b18bf0c3a 100644 --- a/src/sentry/src/Tracing/Aspect/FilesystemAspect.php +++ b/src/sentry/src/Tracing/Aspect/FilesystemAspect.php @@ -11,102 +11,21 @@ namespace FriendsOfHyperf\Sentry\Tracing\Aspect; -use FriendsOfHyperf\Sentry\Switcher; -use Hyperf\Di\Aop\AbstractAspect; +use FriendsOfHyperf\Sentry\Aspect\FilesystemAspect as BaseFilesystemAspect; use Hyperf\Di\Aop\ProceedingJoinPoint; use Sentry\Tracing\SpanContext; use function Sentry\trace; -class FilesystemAspect extends AbstractAspect +class FilesystemAspect extends BaseFilesystemAspect { - public array $classes = [ - 'League\Flysystem\*\*Adapter::directoryExists', - 'League\Flysystem\*\*Adapter::write', - 'League\Flysystem\*\*Adapter::writeStream', - 'League\Flysystem\*\*Adapter::read', - 'League\Flysystem\*\*Adapter::readStream', - 'League\Flysystem\*\*Adapter::delete', - 'League\Flysystem\*\*Adapter::deleteDirectory', - 'League\Flysystem\*\*Adapter::createDirectory', - 'League\Flysystem\*\*Adapter::setVisibility', - 'League\Flysystem\*\*Adapter::visibility', - 'League\Flysystem\*\*Adapter::mimeType', - 'League\Flysystem\*\*Adapter::lastModified', - 'League\Flysystem\*\*Adapter::fileSize', - 'League\Flysystem\*\*Adapter::listContents', - 'League\Flysystem\*\*Adapter::move', - 'League\Flysystem\*\*Adapter::copy', - - // More adapter methods can be added here - ]; - - public function __construct( - protected Switcher $switcher - ) { - } - public function process(ProceedingJoinPoint $proceedingJoinPoint) { if (! $this->switcher->isTracingEnabled('filesystem')) { return $proceedingJoinPoint->process(); } - $method = $proceedingJoinPoint->methodName; - $arguments = $proceedingJoinPoint->arguments['keys'] ?? []; - // See https://develop.sentry.dev/sdk/performance/span-operations/#web-server - $op = "file.{$method}"; - $description = match ($method) { - 'move', 'copy' => sprintf( - 'from "%s" to "%s"', - $arguments['source'] ?? '', - $arguments['destination'] ?? '' - ), - 'write', 'writeStream', - 'read', 'readStream', - 'setVisibility', 'visibility', - 'delete', 'deleteDirectory', 'createDirectory', - 'fileExists', 'directoryExists', - 'listContents', - 'lastModified', - 'fileSize', - 'mimeType', => $arguments['path'] ?? '', - default => '', - }; - - $data = match ($method) { - 'move', 'copy' => [ - 'from' => $arguments['source'] ?? '', - 'to' => $arguments['destination'] ?? '', - ], - 'write', 'writeStream' => [ - 'path' => $arguments['path'] ?? '', - 'config' => $arguments['config'] ?? null, - ], - 'read', 'readStream' => [ - 'path' => $arguments['path'] ?? '', - ], - 'setVisibility' => [ - 'path' => $arguments['path'] ?? '', - 'visibility' => $arguments['visibility'] ?? '', - ], - 'visibility', - 'delete', 'deleteDirectory' => [ - 'path' => $arguments['path'] ?? '', - ], - 'createDirectory' => [ - 'path' => $arguments['path'] ?? '', - 'config' => $arguments['config'] ?? null, - ], - 'fileExists', 'directoryExists', - 'listContents', - 'lastModified', - 'fileSize', - 'mimeType' => [ - 'path' => $arguments['path'] ?? '', - ], - default => [], - }; + [$op, $description, $data] = $this->getSentryMetadata($proceedingJoinPoint); return trace( fn () => $proceedingJoinPoint->process(), From 8f647035aae4857518c09f623b52edfaef6e2a91 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 09:33:57 +0800 Subject: [PATCH 06/10] refactor(sentry): update FilesystemAspect property and constructor syntax for clarity --- src/sentry/src/Aspect/FilesystemAspect.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sentry/src/Aspect/FilesystemAspect.php b/src/sentry/src/Aspect/FilesystemAspect.php index cfcdfad08..1eb233f9c 100644 --- a/src/sentry/src/Aspect/FilesystemAspect.php +++ b/src/sentry/src/Aspect/FilesystemAspect.php @@ -19,7 +19,7 @@ class FilesystemAspect extends AbstractAspect { - public $classes = [ + public array $classes = [ 'League\Flysystem\*\*Adapter::directoryExists', 'League\Flysystem\*\*Adapter::write', 'League\Flysystem\*\*Adapter::writeStream', @@ -40,9 +40,8 @@ class FilesystemAspect extends AbstractAspect // More adapter methods can be added here ]; - public function __construct( - protected Switcher $switcher - ) { + public function __construct(protected Switcher $switcher) + { } public function process(ProceedingJoinPoint $proceedingJoinPoint) From 09bc3baebc5139d7857a2295763598d15cc43709 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 09:35:07 +0800 Subject: [PATCH 07/10] refactor(sentry): add #[Override] attribute to process method in FilesystemAspect for clarity --- src/sentry/src/Tracing/Aspect/FilesystemAspect.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sentry/src/Tracing/Aspect/FilesystemAspect.php b/src/sentry/src/Tracing/Aspect/FilesystemAspect.php index b18bf0c3a..319c8c943 100644 --- a/src/sentry/src/Tracing/Aspect/FilesystemAspect.php +++ b/src/sentry/src/Tracing/Aspect/FilesystemAspect.php @@ -13,12 +13,14 @@ use FriendsOfHyperf\Sentry\Aspect\FilesystemAspect as BaseFilesystemAspect; use Hyperf\Di\Aop\ProceedingJoinPoint; +use Override; use Sentry\Tracing\SpanContext; use function Sentry\trace; class FilesystemAspect extends BaseFilesystemAspect { + #[Override] public function process(ProceedingJoinPoint $proceedingJoinPoint) { if (! $this->switcher->isTracingEnabled('filesystem')) { From 9191a7968f2f80dde7fd5bd4c906d250a4041947 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 09:39:27 +0800 Subject: [PATCH 08/10] refactor(sentry): add 'fileExists' method to FilesystemAspect class for completeness --- src/sentry/src/Aspect/FilesystemAspect.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sentry/src/Aspect/FilesystemAspect.php b/src/sentry/src/Aspect/FilesystemAspect.php index 1eb233f9c..47e22b32b 100644 --- a/src/sentry/src/Aspect/FilesystemAspect.php +++ b/src/sentry/src/Aspect/FilesystemAspect.php @@ -20,6 +20,7 @@ class FilesystemAspect extends AbstractAspect { public array $classes = [ + 'League\Flysystem\*\*Adapter::fileExists', 'League\Flysystem\*\*Adapter::directoryExists', 'League\Flysystem\*\*Adapter::write', 'League\Flysystem\*\*Adapter::writeStream', From acde4d155c773d9d0f29fab2e18160162cdd2683 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 09:41:51 +0800 Subject: [PATCH 09/10] refactor(sentry): add 'config' argument to move and copy operations in FilesystemAspect for improved flexibility --- src/sentry/src/Aspect/FilesystemAspect.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sentry/src/Aspect/FilesystemAspect.php b/src/sentry/src/Aspect/FilesystemAspect.php index 47e22b32b..42996bd04 100644 --- a/src/sentry/src/Aspect/FilesystemAspect.php +++ b/src/sentry/src/Aspect/FilesystemAspect.php @@ -94,6 +94,7 @@ protected function getSentryMetadata(ProceedingJoinPoint $proceedingJoinPoint): 'move', 'copy' => [ 'from' => $arguments['source'] ?? '', 'to' => $arguments['destination'] ?? '', + 'config' => $arguments['config'] ?? null, ], 'write', 'writeStream' => [ 'path' => $arguments['path'] ?? '', From c1107ac95d75834c59dc18fd4abc039831630871 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 21 Sep 2025 09:47:44 +0800 Subject: [PATCH 10/10] refactor(sentry): enhance metadata handling in FilesystemAspect for move and copy operations --- src/sentry/src/Aspect/FilesystemAspect.php | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/sentry/src/Aspect/FilesystemAspect.php b/src/sentry/src/Aspect/FilesystemAspect.php index 42996bd04..63a4737c9 100644 --- a/src/sentry/src/Aspect/FilesystemAspect.php +++ b/src/sentry/src/Aspect/FilesystemAspect.php @@ -90,36 +90,39 @@ protected function getSentryMetadata(ProceedingJoinPoint $proceedingJoinPoint): 'mimeType', => $arguments['path'] ?? '', default => '', }; + + $config = null; + + if (isset($arguments['config'])) { + if (is_object($arguments['config']) && method_exists($arguments['config'], 'toArray')) { + $config = $arguments['config']->toArray(); + } else { + $config = $arguments['config']; + } + } + $data = match ($method) { 'move', 'copy' => [ 'from' => $arguments['source'] ?? '', 'to' => $arguments['destination'] ?? '', - 'config' => $arguments['config'] ?? null, - ], - 'write', 'writeStream' => [ - 'path' => $arguments['path'] ?? '', - 'config' => $arguments['config'] ?? null, + 'config' => $config, ], - 'read', 'readStream' => [ + 'write', 'writeStream', 'createDirectory' => [ 'path' => $arguments['path'] ?? '', + 'config' => $config, ], 'setVisibility' => [ 'path' => $arguments['path'] ?? '', 'visibility' => $arguments['visibility'] ?? '', ], - 'visibility', - 'delete', 'deleteDirectory' => [ + 'listContents' => [ 'path' => $arguments['path'] ?? '', + 'deep' => $arguments['deep'] ?? false, ], - 'createDirectory' => [ - 'path' => $arguments['path'] ?? '', - 'config' => $arguments['config'] ?? null, - ], + 'read', 'readStream', + 'visibility', 'delete', 'deleteDirectory', 'fileExists', 'directoryExists', - 'listContents', - 'lastModified', - 'fileSize', - 'mimeType' => [ + 'lastModified', 'fileSize', 'mimeType' => [ 'path' => $arguments['path'] ?? '', ], default => [],