diff --git a/app/Exceptions/Trackers/Sentry.php b/app/Exceptions/Trackers/Sentry.php index d8b720d66..cb9fe7e3e 100644 --- a/app/Exceptions/Trackers/Sentry.php +++ b/app/Exceptions/Trackers/Sentry.php @@ -17,6 +17,7 @@ class Sentry 'company_id' => (string) company_id(), 'locale' => (string) app()->getLocale(), 'timezone' => (string) config('app.timezone'), + 'app_type' => (string) static::getAppType(), ]); return $event; @@ -24,14 +25,14 @@ class Sentry public static function tracesSampler(SamplingContext $context): float { - if (static::filterAgent()) { + if (static::shouldFilterAgent()) { return 0.0; } return config('sentry.traces_sample_rate'); } - public static function filterAgent(): bool + public static function shouldFilterAgent(): bool { $user_agent = request()->userAgent(); @@ -47,4 +48,23 @@ class Sentry return false; } + + public static function getAppType() + { + $hostname = gethostname(); + + if (Str::contains($hostname, '-queue-')) { + $app_type = 'queue'; + } elseif (Str::contains($hostname, '-cron-')) { + $app_type = 'cron'; + } elseif (request()->isApi()) { + $app_type = 'api'; + } elseif (app()->runningInConsole()) { + $app_type = 'console'; + } else { + $app_type = 'ui'; + } + + return $app_type; + } } diff --git a/config/sentry.php b/config/sentry.php index b76b2ed9f..5c9efd700 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -50,7 +50,7 @@ return [ // @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii 'send_default_pii' => env('SENTRY_SEND_DEFAULT_PII', true), - 'traces_sample_rate' => (float)(env('SENTRY_TRACES_SAMPLE_RATE', 1.0)), + 'traces_sample_rate' => (float)(env('SENTRY_TRACES_SAMPLE_RATE', 0.0)), 'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'),