File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/Sentry/Laravel/Features Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 66use Illuminate \Contracts \Events \Dispatcher ;
77use Illuminate \Redis \Events as RedisEvents ;
88use Illuminate \Redis \RedisManager ;
9+ use Illuminate \Support \Str ;
910use Sentry \Breadcrumb ;
1011use Sentry \Laravel \Features \Concerns \ResolvesEventOrigin ;
1112use Sentry \Laravel \Integration ;
@@ -81,7 +82,16 @@ public function handleRedisCommand(RedisEvents\CommandExecuted $event): void
8182
8283 $ context = new SpanContext ();
8384 $ context ->setOp ('db.redis ' );
84- $ context ->setDescription (strtoupper ($ event ->command ) . ' ' . ($ event ->parameters [0 ] ?? null ));
85+
86+ $ keyForDescription = '' ;
87+
88+ // If the first parameter is a string and does not contain a newline we use it as the description since it's most likely a key
89+ // This is not a perfect solution but it's the best we can do without understanding the command that was executed
90+ if (!empty ($ event ->parameters [0 ]) && is_string ($ event ->parameters [0 ]) && !Str::contains ($ event ->parameters [0 ], "\n" )) {
91+ $ keyForDescription = $ event ->parameters [0 ];
92+ }
93+
94+ $ context ->setDescription (rtrim (strtoupper ($ event ->command ) . ' ' . $ keyForDescription ));
8595 $ context ->setStartTimestamp (microtime (true ) - $ event ->time / 1000 );
8696 $ context ->setEndTimestamp ($ context ->getStartTimestamp () + $ event ->time / 1000 );
8797
You can’t perform that action at this time.
0 commit comments