Mallow's Blog

LARAVEL TELESCOPE – A Debugging Tool

Debugging is a multi-step process that involves in the identification of bugs and errors which can be handled by using debugging tools. The use of debugging tools helps us in identifying various bugs in our application. 

Laravel Telescope is an open source debugging assistant for the Laravel framework written by Taylor Otwell. Laravel Telescope is free on Github and it can be pulled into your project application as a dependency using the composer. It can also be installed for local development by using the dev flag. Once installed, it can be accessed by visiting the route /telescope of the application which opens up an interactive user interface to monitor various aspects of your project. Basically telescope comprises of a series of watchers that constantly ‘watch’ every request.

Laravel Telescope

TOP FEATURES OF LARAVEL TELESCOPE:

  • Telescope provides monitoring capabilities for monitoring the requests that come into your application including commands, scheduled commands, jobs, exceptions, logs, dumps, queries, models, events, mails, notifications and cache activities.
  • Telescope consists of a primary configuration file that allows the developer to configure based on his needs at the config/telescope.php. This file allows us to customize the watcher options.
  • One of the major features of telescope is data pruning. When data pruning is activated, the records will get cleared so that the database doesn’t  accumulate with the data, once in 24 hours. By scheduling the command in Laravel, we can customize the time interval at which it should run.
  • You can also modify the number of queries that are being allowed at a time. The default Telescope_limit is 100. You can configure it based on your needs.
  • The Laravel TelescopeServiceProvider allows us to filter the data monitored by the telescope by filter callback that is registered in the service provider. By default, telescope monitors and stores all the data and it can be customized based on the needs.
  • Telescope watchers gather application data when a request or console command is executed. You may customize the list of watchers that you would like to enable within your config/telescope.php configuration file. There are several watchers that can be added as per our use cases.
  • The Telescope watchers collect the application data when any request or activity is executed in your application. In the config/telescope.php configuration file, you can explicitly specify the list of watchers that you want to enable and the activity is monitored and stored based on the watchers you specify. 
  • The Cache watcher records all the cache hits and deletes. You can see the cache key, its own expiration time and time regarding its creation. Redis watcher is also similar to the Cache watcher.  It records all the time taken, and request initiated time in Redis.
  • The command watcher records all the commands that are being run in the application and their exit codes including all the arguments along with options of the command.
  • The dump watcher records and displays your variable dumps in Telescope. In Laravel, when you use dump() method you will get the data on the dump screen in the Telescope. When the dump screen is initiated on the Telescope all the dumps in the application gets directed to the telescope and it doesn’t affect the running of the application on the browser. But once the dump screen is closed, all of a sudden all the dump contents get displayed on the actual browser.
  • The event watcher enables you to monitor all the events that has been triggered by your application. You can see all the events that are broadcasted with a tag on it. It also stores all the data regarding the event occurrence.
  • The mail watcher shows all the e-mails sent, it’s timing, recipients and the status whether it is queued or sent. We can see the entire mail along with its content and it can also be downloaded as an .eml file and can be opened.
Laravel Telescope
  • The query watcher records the SQL queries that have been executed throughout the application. It also shows the nature and speed of the query and differentiates it based on various aspects like response time
Laravel Telescope
  • There are a lot more watchers that are supported in telescope and they serve their purpose accordingly.
  • Authorization can be enabled in Telescope where you can add a list of emails in the Telescope service provider thereby providing them access on production.
  • Telescope can be run on both local and in production environment. If used in production environment, it is best to move the telescope in a separate database for easier handling. Telescope also has built-in authorization and tools for protecting private data. You can also ensure private data doesn’t get logged on production.

So from this post we have seen the various features of Laravel Telescope. It is both development friendly and production friendly. Thus the use of Laravel Telescope will make it easier for the process of monitoring and debugging.

Ajit T.,
PHP Team,
Mallow technologies

Leave a Reply

%d bloggers like this: