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 6
6
use Illuminate \Contracts \Events \Dispatcher ;
7
7
use Illuminate \Redis \Events as RedisEvents ;
8
8
use Illuminate \Redis \RedisManager ;
9
+ use Illuminate \Support \Str ;
9
10
use Sentry \Breadcrumb ;
10
11
use Sentry \Laravel \Features \Concerns \ResolvesEventOrigin ;
11
12
use Sentry \Laravel \Integration ;
@@ -81,7 +82,16 @@ public function handleRedisCommand(RedisEvents\CommandExecuted $event): void
81
82
82
83
$ context = new SpanContext ();
83
84
$ 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 ));
85
95
$ context ->setStartTimestamp (microtime (true ) - $ event ->time / 1000 );
86
96
$ context ->setEndTimestamp ($ context ->getStartTimestamp () + $ event ->time / 1000 );
87
97
You can’t perform that action at this time.
0 commit comments