Set up Telescope

This commit is contained in:
Jonny Barnes 2019-03-29 17:53:43 +00:00
parent 27638226fa
commit 3c468be081
12 changed files with 442 additions and 2 deletions

View file

@ -27,6 +27,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->command('telescope:prune --hours=48')->daily();
}
/**

View file

@ -0,0 +1,70 @@
<?php
namespace App\Providers;
use Laravel\Telescope\Telescope;
use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// Telescope::night();
$this->hideSensitiveRequestDetails();
Telescope::filter(function (IncomingEntry $entry) {
if ($this->app->isLocal()) {
return true;
}
return $entry->isReportableException() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}
/**
* Prevent sensitive request details from being logged by Telescope.
*
* @return void
*/
protected function hideSensitiveRequestDetails()
{
if ($this->app->isLocal()) {
return;
}
Telescope::hideRequestParameters(['_token']);
Telescope::hideRequestHeaders([
'cookie',
'x-csrf-token',
'x-xsrf-token',
]);
}
/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->name, [
'jonny',
]);
});
}
}

View file

@ -21,6 +21,7 @@
"laravel/framework": "5.8.*",
"laravel/horizon": "^3.0",
"laravel/scout": "^7.0",
"laravel/telescope": "^2.0",
"laravel/tinker": "^1.0",
"lcobucci/jwt": "^3.1",
"league/commonmark": "^0.18.0",

115
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a1bedd7340f6f8a2fdcc375d3bc5672c",
"content-hash": "599dcecaa4ed56e594737b12e86eb6b7",
"packages": [
{
"name": "aws/aws-sdk-php",
@ -2011,6 +2011,68 @@
],
"time": "2019-02-14T16:50:18+00:00"
},
{
"name": "laravel/telescope",
"version": "v2.0.4",
"source": {
"type": "git",
"url": "https://github.com/laravel/telescope.git",
"reference": "eb3f6f8337050cc31fe1a1164240fe205e33b167"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/telescope/zipball/eb3f6f8337050cc31fe1a1164240fe205e33b167",
"reference": "eb3f6f8337050cc31fe1a1164240fe205e33b167",
"shasum": ""
},
"require": {
"ext-json": "*",
"laravel/framework": "~5.8.0|~5.9.0",
"moontoast/math": "^1.1",
"php": "^7.1.3",
"symfony/var-dumper": "^4.1"
},
"require-dev": {
"orchestra/testbench": "~3.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
},
"laravel": {
"providers": [
"Laravel\\Telescope\\TelescopeServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Telescope\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
},
{
"name": "Mohamed Said",
"email": "mohamed@laravel.com"
}
],
"description": "An elegant debug assistant for the Laravel framework.",
"keywords": [
"debugging",
"laravel",
"monitoring"
],
"time": "2019-03-28T05:06:56+00:00"
},
{
"name": "laravel/tinker",
"version": "v1.0.8",
@ -2716,6 +2778,55 @@
],
"time": "2018-11-05T09:00:11+00:00"
},
{
"name": "moontoast/math",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/ramsey/moontoast-math.git",
"reference": "c2792a25df5cad4ff3d760dd37078fc5b6fccc79"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/moontoast-math/zipball/c2792a25df5cad4ff3d760dd37078fc5b6fccc79",
"reference": "c2792a25df5cad4ff3d760dd37078fc5b6fccc79",
"shasum": ""
},
"require": {
"ext-bcmath": "*",
"php": ">=5.3.3"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "^0.9.0",
"phpunit/phpunit": "^4.7|>=5.0 <5.4",
"satooshi/php-coveralls": "^0.6.1",
"squizlabs/php_codesniffer": "^2.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Moontoast\\Math\\": "src/Moontoast/Math/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Ben Ramsey",
"email": "ben@benramsey.com",
"homepage": "https://benramsey.com"
}
],
"description": "A mathematics library, providing functionality for large numbers",
"homepage": "https://github.com/ramsey/moontoast-math",
"keywords": [
"bcmath",
"math"
],
"time": "2017-02-16T16:54:46+00:00"
},
{
"name": "mtdowling/jmespath.php",
"version": "2.4.0",
@ -4606,7 +4717,7 @@
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
"email": "backendtea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",

View file

@ -202,6 +202,7 @@ return [
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
App\Providers\RouteServiceProvider::class,

155
config/telescope.php Normal file
View file

@ -0,0 +1,155 @@
<?php
use Laravel\Telescope\Watchers;
use Laravel\Telescope\Http\Middleware\Authorize;
return [
/*
|--------------------------------------------------------------------------
| Telescope Domain
|--------------------------------------------------------------------------
|
| This is the subdomain where Telescope will be accessible from. If the
| setting is null, Telescope will reside under the same domain as the
| application. Otherwise, this value will be used as the subdomain.
|
*/
'domain' => null,
/*
|--------------------------------------------------------------------------
| Telescope Path
|--------------------------------------------------------------------------
|
| This is the URI path where Telescope will be accessible from. Feel free
| to change this path to anything you like. Note that the URI will not
| affect the paths of its internal API that aren't exposed to users.
|
*/
'path' => 'telescope',
/*
|--------------------------------------------------------------------------
| Telescope Storage Driver
|--------------------------------------------------------------------------
|
| This configuration options determines the storage driver that will
| be used to store Telescope's data. In addition, you may set any
| custom options as needed by the particular driver you choose.
|
*/
'driver' => env('TELESCOPE_DRIVER', 'database'),
'storage' => [
'database' => [
'connection' => env('DB_CONNECTION', 'mysql'),
],
],
/*
|--------------------------------------------------------------------------
| Telescope Master Switch
|--------------------------------------------------------------------------
|
| This option may be used to disable all Telescope watchers regardless
| of their individual configuration, which simply provides a single
| and convenient way to enable or disable Telescope data storage.
|
*/
'enabled' => env('TELESCOPE_ENABLED', true),
/*
|--------------------------------------------------------------------------
| Telescope Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Telescope route, giving you
| the chance to add your own middleware to this list or change any of
| the existing middleware. Or, you can simply stick with this list.
|
*/
'middleware' => [
'web',
Authorize::class,
],
/*
|--------------------------------------------------------------------------
| Ignored Paths & Commands
|--------------------------------------------------------------------------
|
| The following array lists the URI paths and Artisan commands that will
| not be watched by Telescope. In addition to this list, some Laravel
| commands, like migrations and queue commands, are always ignored.
|
*/
'ignore_paths' => [
//
],
'ignore_commands' => [
//
],
/*
|--------------------------------------------------------------------------
| Telescope Watchers
|--------------------------------------------------------------------------
|
| The following array lists the "watchers" that will be registered with
| Telescope. The watchers gather the application's profile data when
| a request or task is executed. Feel free to customize this list.
|
*/
'watchers' => [
Watchers\CacheWatcher::class => env('TELESCOPE_CACHE_WATCHER', true),
Watchers\CommandWatcher::class => [
'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
'ignore' => [],
],
Watchers\DumpWatcher::class => env('TELESCOPE_DUMP_WATCHER', true),
Watchers\EventWatcher::class => env('TELESCOPE_EVENT_WATCHER', true),
Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
Watchers\LogWatcher::class => env('TELESCOPE_LOG_WATCHER', true),
Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
Watchers\ModelWatcher::class => [
'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
'events' => ['eloquent.*'],
],
Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
Watchers\QueryWatcher::class => [
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
'ignore_packages' => true,
'slow' => 100,
],
Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
Watchers\RequestWatcher::class => [
'enabled' => env('TELESCOPE_REQUEST_WATCHER', true),
'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64),
],
Watchers\GateWatcher::class => [
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
'ignore_abilities' => [],
'ignore_packages' => true,
],
Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
],
];

View file

@ -0,0 +1,79 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTelescopeEntriesTable extends Migration
{
/**
* The database schema.
*
* @var Schema
*/
protected $schema;
/**
* Create a new migration instance.
*
* @return void
*/
public function __construct()
{
$this->schema = Schema::connection(
config('telescope.storage.database.connection')
);
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$this->schema->create('telescope_entries', function (Blueprint $table) {
$table->bigIncrements('sequence');
$table->uuid('uuid');
$table->uuid('batch_id');
$table->string('family_hash')->nullable()->index();
$table->boolean('should_display_on_index')->default(true);
$table->string('type', 20);
$table->longText('content');
$table->dateTime('created_at')->nullable();
$table->unique('uuid');
$table->index('batch_id');
$table->index(['type', 'should_display_on_index']);
});
$this->schema->create('telescope_entries_tags', function (Blueprint $table) {
$table->uuid('entry_uuid');
$table->string('tag');
$table->index(['entry_uuid', 'tag']);
$table->index('tag');
$table->foreign('entry_uuid')
->references('uuid')
->on('telescope_entries')
->onDelete('cascade');
});
$this->schema->create('telescope_monitoring', function (Blueprint $table) {
$table->string('tag');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$this->schema->dropIfExists('telescope_entries_tags');
$this->schema->dropIfExists('telescope_entries');
$this->schema->dropIfExists('telescope_monitoring');
}
}

8
public/vendor/telescope/app-dark.css vendored Normal file

File diff suppressed because one or more lines are too long

8
public/vendor/telescope/app.css vendored Normal file

File diff suppressed because one or more lines are too long

1
public/vendor/telescope/app.js vendored Normal file

File diff suppressed because one or more lines are too long

BIN
public/vendor/telescope/favicon.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View file

@ -0,0 +1,5 @@
{
"/app.js": "/app.js?id=8776cf12ba6d7c72f145",
"/app.css": "/app.css?id=3c765b0499c4e3802fa7",
"/app-dark.css": "/app-dark.css?id=ff722ac6ef71817088c1"
}