Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.1",
"php-debugbar/php-debugbar": "~2.2.0",
"php-debugbar/php-debugbar": "^2.2.4",
"illuminate/routing": "^9|^10|^11|^12",
"illuminate/session": "^9|^10|^11|^12",
"illuminate/support": "^9|^10|^11|^12",
Expand Down
3 changes: 2 additions & 1 deletion config/debugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@
],
'hints' => env('DEBUGBAR_OPTIONS_DB_HINTS', false), // Show hints for common mistakes
'show_copy' => env('DEBUGBAR_OPTIONS_DB_SHOW_COPY', true), // Show copy button next to the query,
'slow_threshold' => env('DEBUGBAR_OPTIONS_DB_SLOW_THRESHOLD', false), // Only track queries that last longer than this time in ms
'only_slow_queries' => env('DEBUGBAR_OPTIONS_DB_ONLY_SLOW_QUERIES', true), // Only track queries that last longer than `slow_threshold`
'slow_threshold' => env('DEBUGBAR_OPTIONS_DB_SLOW_THRESHOLD', false), // Max query execution time (ms). Exceeding queries will be highlighted
'memory_usage' => env('DEBUGBAR_OPTIONS_DB_MEMORY_USAGE', false), // Show queries memory usage
'soft_limit' => (int) env('DEBUGBAR_OPTIONS_DB_SOFT_LIMIT', 100), // After the soft limit, no parameters/backtrace are captured
'hard_limit' => (int) env('DEBUGBAR_OPTIONS_DB_HARD_LIMIT', 500), // After the hard limit, queries are ignored
Expand Down
1 change: 1 addition & 0 deletions src/DataCollector/QueryCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ public function collect()
'start' => $query['start'] ?? null,
'duration' => $query['time'],
'duration_str' => ($query['type'] == 'transaction') ? '' : $this->formatDuration($query['time']),
'slow' => $this->slowThreshold && $this->slowThreshold <= $query['time'],
'memory' => $query['memory'],
'memory_str' => $query['memory'] ? $this->getDataFormatter()->formatBytes($query['memory']) : null,
'filename' => $this->getDataFormatter()->formatSource($source, true),
Expand Down
10 changes: 8 additions & 2 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ function (\Illuminate\Log\Events\MessageLogged $log) use ($logger) {
$queryCollector->setLimits($config->get('debugbar.options.db.soft_limit'), $config->get('debugbar.options.db.hard_limit'));
$queryCollector->setDurationBackground($config->get('debugbar.options.db.duration_background'));

$threshold = $config->get('debugbar.options.db.slow_threshold', false);
if ($threshold && !$config->get('debugbar.options.db.only_slow_queries', true)) {
$queryCollector->setSlowThreshold($threshold);
}

if ($config->get('debugbar.options.db.with_params')) {
$queryCollector->setRenderSqlWithParams(true);
}
Expand Down Expand Up @@ -402,9 +407,10 @@ function (\Illuminate\Database\Events\QueryExecuted $query) {
return; // Issue 776 : We've turned off collecting after the listener was attached
}

//allow collecting only queries slower than a specified amount of milliseconds
$threshold = app('config')->get('debugbar.options.db.slow_threshold', false);
if (!$threshold || $query->time > $threshold) {
$onlyThreshold = app('config')->get('debugbar.options.db.only_slow_queries', true);
//allow collecting only queries slower than a specified amount of milliseconds
if (!$onlyThreshold || !$threshold || $query->time > $threshold) {
$this['queries']->addQuery($query);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/queries/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@
.attr('data-duplicate', false)
.append($('<strong />').addClass(csscls('sql name')).text(statement.sql));
} else {
if (statement.slow) {
$li.addClass(csscls('sql-slow'));
}
const $code = $('<code />').html(PhpDebugBar.Widgets.highlight(statement.sql, 'sql')).addClass(csscls('sql')),
duplicated = this.duplicateQueries.has(statement);
$li.attr('data-connection', statement.connection)
Expand Down
Loading