Skip to content

Commit

Permalink
Add the Ability to Pass Custom ignore_paths To Query Watcher (#1276)
Browse files Browse the repository at this point in the history
* Add the ability to ignore custom paths to QueryWatcher

* Linting

* Update FetchesStackTrace.php

* Update FetchesStackTrace.php

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
Watercycle and taylorotwell authored Dec 5, 2022
1 parent 9ec23b1 commit e4b16dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/telescope.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
'ignore_abilities' => [],
'ignore_packages' => true,
'ignore_paths' => [],
],

Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
Expand All @@ -162,6 +163,7 @@
Watchers\QueryWatcher::class => [
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
'ignore_packages' => true,
'ignore_paths' => [],
'slow' => 100,
],

Expand Down
19 changes: 15 additions & 4 deletions src/Watchers/FetchesStackTrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,25 @@ protected function getCallerFromStackTrace($forgetLines = 0)
return false;
}

return ! Str::contains($frame['file'],
base_path('vendor'.DIRECTORY_SEPARATOR.$this->ignoredVendorPath())
);
return ! Str::contains($frame['file'], $this->ignoredPaths());
});
}

/**
* Choose the frame outside of either Telescope/Laravel or all packages.
* Get the file paths that should not be used by backtraces.
*
* @return array
*/
protected function ignoredPaths(): array
{
return array_merge(
[base_path('vendor'.DIRECTORY_SEPARATOR.$this->ignoredVendorPath())],
$this->options['ignore_paths'] ?? []
);
}

/**
* Choose the frame outside of either Telescope / Laravel or all packages.
*
* @return string|null
*/
Expand Down

0 comments on commit e4b16dd

Please sign in to comment.