Skip to content

Commit 6fc88b3

Browse files
kima92taylorotwell
andauthored
limit sql length to avoid breaking the json (#326)
* limit sql length to avoid breaking the json * Added as config+env var * Update pulse.php * Update SlowQueries.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 5285c67 commit 6fc88b3

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Diff for: config/pulse.php

+1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
'threshold' => env('PULSE_SLOW_QUERIES_THRESHOLD', 1000),
197197
'location' => env('PULSE_SLOW_QUERIES_LOCATION', true),
198198
'highlighting' => env('PULSE_SLOW_QUERIES_HIGHLIGHTING', true),
199+
'max_query_length' => env('PULSE_SLOW_QUERIES_MAX_QUERY_LENGTH', null),
199200
'ignore' => [
200201
'/(["`])pulse_[\w]+?\1/', // Pulse tables...
201202
'/(["`])telescope_[\w]+?\1/', // Telescope tables...

Diff for: src/Recorders/SlowQueries.php

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function record(QueryExecuted $event): void
5555
return;
5656
}
5757

58+
if ($maxQueryLength = $this->config->get('pulse.recorders.'.self::class.'.max_query_length')) {
59+
$sql = Str::limit($sql, $maxQueryLength);
60+
}
61+
5862
$this->pulse->record(
5963
type: 'slow_query',
6064
key: json_encode([$sql, $location], flags: JSON_THROW_ON_ERROR),

0 commit comments

Comments
 (0)