diff --git a/config/pulse.php b/config/pulse.php index 68ee12b4..2eb95ccc 100644 --- a/config/pulse.php +++ b/config/pulse.php @@ -196,6 +196,7 @@ 'threshold' => env('PULSE_SLOW_QUERIES_THRESHOLD', 1000), 'location' => env('PULSE_SLOW_QUERIES_LOCATION', true), 'highlighting' => env('PULSE_SLOW_QUERIES_HIGHLIGHTING', true), + 'max_query_length' => env('PULSE_SLOW_QUERIES_MAX_QUERY_LENGTH', null), 'ignore' => [ '/(["`])pulse_[\w]+?\1/', // Pulse tables... '/(["`])telescope_[\w]+?\1/', // Telescope tables... diff --git a/src/Recorders/SlowQueries.php b/src/Recorders/SlowQueries.php index a1e74ef0..6f0b5791 100644 --- a/src/Recorders/SlowQueries.php +++ b/src/Recorders/SlowQueries.php @@ -55,6 +55,10 @@ public function record(QueryExecuted $event): void return; } + if ($maxQueryLength = $this->config->get('pulse.recorders.'.self::class.'.max_query_length')) { + $sql = Str::limit($sql, $maxQueryLength); + } + $this->pulse->record( type: 'slow_query', key: json_encode([$sql, $location], flags: JSON_THROW_ON_ERROR),