Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotlight improvements #892

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/
'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')),

// @see https://spotlightjs.com/
// 'spotlight' => env('SENTRY_SPOTLIGHT', false),

// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#logger
// 'logger' => Sentry\Logger\DebugFileLogger::class, // By default this will log to `storage_path('logs/sentry.log')`

Expand Down
16 changes: 15 additions & 1 deletion src/Sentry/Laravel/BaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ protected function hasDsnSet(): bool
return !empty($config['dsn']);
}

/**
* Check if Spotlight was enabled in the config.
*
* @return bool
*/
protected function hasSpotlightEnabled(): bool
{
$config = $this->getUserConfig();

return ($config['spotlight'] ?? false) === true;
}

/**
* Retrieve the user configuration.
*
Expand All @@ -42,12 +54,14 @@ protected function getUserConfig(): array
*
* Because of `traces_sampler` being dynamic we can never be 100% confident but that is also not important.
*
* @deprecated since version 4.6. To be removed in version 5.0.
*
* @return bool
*/
protected function couldHavePerformanceTracingEnabled(): bool
{
$config = $this->getUserConfig();

return !empty($config['traces_sample_rate']) || !empty($config['traces_sampler']);
return !empty($config['traces_sample_rate']) || !empty($config['traces_sampler']) || ($config['spotlight'] ?? false) === true;
}
}
4 changes: 2 additions & 2 deletions src/Sentry/Laravel/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function boot(): void

$this->bootFeatures();

if ($this->hasDsnSet()) {
if ($this->hasDsnSet() || $this->hasSpotlightEnabled()) {
$this->bindEvents();

if ($this->app instanceof Lumen) {
Expand Down Expand Up @@ -188,7 +188,7 @@ protected function registerFeatures(): void
*/
protected function bootFeatures(): void
{
$bootActive = $this->hasDsnSet();
$bootActive = $this->hasDsnSet() || $this->hasSpotlightEnabled();

foreach (self::FEATURES as $feature) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Laravel/Tracing/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ServiceProvider extends BaseServiceProvider
public function boot(): void
{
// If there is no DSN set we register nothing since it's impossible for us to send traces without a DSN set
stayallive marked this conversation as resolved.
Show resolved Hide resolved
if (!$this->hasDsnSet()) {
if (!$this->hasDsnSet() && !$this->hasSpotlightEnabled()) {
return;
}

Expand Down