add Sentry

This commit is contained in:
Irfan 2021-09-11 19:36:27 +05:00
parent c23edefe4a
commit 8c2e3c682f
8 changed files with 1273 additions and 4 deletions

View File

@ -115,4 +115,20 @@ PATREON_CLIENT_SECRET=
###
# OpenAPI
###
SWAGGER_VERSION=3.0
SWAGGER_VERSION=3.0
###
# API call insights
###
# Enable/Disable insights API system
INSIGHTS=true
# Max requests store in seconds - default 2 days
INSIGHTS_MAX_STORE_TIME=172800
###
# Error reporting
###
REPORTING=true
REPORTING_DRIVER=sentry
SENTRY_LARAVEL_DSN="https://examplePublicKey@o0.ingest.sentry.io/0"
SENTRY_TRACES_SAMPLE_RATE=1

View File

@ -57,6 +57,10 @@ class Handler extends ExceptionHandler
{
$githubReport = GithubReport::make($e, $request);
if (app()->bound('sentry') && $this->shouldReport($e)) {
app('sentry')->captureException($e);
}
// ConnectionException from Redis server
if ($e instanceof ConnectionException) {
/*

View File

@ -79,6 +79,7 @@ class AnimeController extends Controller
*/
public function main(Request $request, int $id)
{
throw new Exception('My first Sentry error!');
$results = Anime::query()
->where('mal_id', $id)
->get();

View File

@ -33,6 +33,7 @@ $app = new Laravel\Lumen\Application(
$app->register(Jenssegers\Mongodb\MongodbServiceProvider::class);
$app->withFacades();
$app->withEloquent();
@ -114,6 +115,12 @@ $app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class);
$app->register(\App\Providers\SourceHeartbeatProvider::class);
$app->register(Illuminate\Database\Eloquent\LegacyFactoryServiceProvider::class);
if (env('REPORTING') && env('REPORTING_DRIVER') === 'sentry') {
$app->register(\Sentry\Laravel\ServiceProvider::class);
// Sentry Performance Monitoring (optional)
$app->register(\Sentry\Laravel\Tracing\ServiceProvider::class);
}
// Guzzle removed as of lumen 8.x
//$guzzleClient = new \GuzzleHttp\Client([
// 'timeout' => env('SOURCE_TIMEOUT', 5),

View File

@ -22,6 +22,7 @@
"league/flysystem": "^1.0",
"ocramius/package-versions": "^1.4",
"predis/predis": "^1.1",
"sentry/sentry-laravel": "^2.8",
"soatok/patreon": "^0.6.0",
"symfony/yaml": "^4.1",
"vlucas/phpdotenv": "^5",

1187
composer.lock generated

File diff suppressed because it is too large Load Diff

57
config/sentry.php Normal file
View File

@ -0,0 +1,57 @@
<?php
return [
'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')),
// capture release as git sha
// 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')),
// When left empty or `null` the Laravel environment will be used
'environment' => env('SENTRY_ENVIRONMENT'),
'breadcrumbs' => [
// Capture Laravel logs in breadcrumbs
'logs' => true,
// Capture SQL queries in breadcrumbs
'sql_queries' => true,
// Capture bindings on SQL queries logged in breadcrumbs
'sql_bindings' => true,
// Capture queue job information in breadcrumbs
'queue_info' => true,
// Capture command information in breadcrumbs
'command_info' => true,
],
'tracing' => [
// Trace queue jobs as their own transactions
'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', false),
// Capture queue jobs as spans when executed on the sync driver
'queue_jobs' => true,
// Capture SQL queries as spans
'sql_queries' => true,
// Try to find out where the SQL query originated from and add it to the query spans
'sql_origin' => true,
// Capture views as spans
'views' => true,
// Indicates if the tracing integrations supplied by Sentry should be loaded
'default_integrations' => true,
],
// @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii
'send_default_pii' => false,
'traces_sample_rate' => (float)(env('SENTRY_TRACES_SAMPLE_RATE', 0.0)),
'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'),
];

View File

@ -45,8 +45,6 @@ $router->get('/', function () use ($router) {
}
);*/
$router->get('/anime', [
'uses' => 'SearchController@anime'
]);