To monitor queued tasks in Laravel's Telescope, you need to manually add the listening event. 1. Open the app/Providers/TelescopeServiceProvider.php file; 2. Introduce and listen to the JobQueued event in the register() method; 3. After the configuration is completed, under the Jobs tag of Telescope, you can view the detailed information of the queued job, including the task class name, queue name and enqueue parameters. This method is suitable for Redis or database-driven queues and supports monitoring of delayed tasks. Note that filtering rules and data security policies should be set reasonably in the online environment to avoid performance problems and sensitive information leakage.
If you are using Laravel's Telescope to monitor queued tasks, especially if you want to view queued tasks, you may find that by default Telescope does not record tasks with these states. This can make troubleshooting or debugging the task process a little cumbersome.
To enable Telescope to monitor queued jobs, some small configuration adjustments are required.
Modify the recording rules of Telescope
By default, Telescope only records processed, failed, and deleted tasks. To also record the queued tasks, you need to modify the listening logic in TelescopeServiceProvider
.
Find register()
method in app/Providers/TelescopeServiceProvider.php
file and add the listening to JobProcessing
event:
use Illuminate\Support\Facades\Bus; use Illuminate\Queue\Events\JobQueued; public function register() { $this->hideSensitiveRequestDetails(); Telescope::filter(function (IncomingEntry $entry) { if ($this->app->isLocal()) { return true; } return false; }); // Add this line to listen for the JobQueued event Telescope::listen([ \Illuminate\Queue\Events\JobQueued::class, ]); }
In this way, when the task is pushed into the queue, it will be captured and recorded by Telescope.
View queued job in Telescope interface
After the configuration is completed, when you trigger a task enqueue operation, you can see the corresponding record under the Jobs tab of Telescope. Each record displays the task class name, connection name, queue name, and serialized task data.
Click on a record to view details, including task parameters, enlistment time and other information. This is very helpful for whether the debugging task is successfully enqueued and whether the parameters are correct.
Note: If you are using Redis or database-driven queues and have set up delay tasks, Telescope can also capture these queued jobs.
FAQs and Suggestions
- Queue environment restrictions : Telescope is enabled only in the local environment by default, and online environments are usually turned off. If you want to record some logs online, remember to control the filtering rules reasonably to avoid performance impact.
-
Data Security : Tasks may contain sensitive data, such as user ID or mailbox. It is important to be careful not to record sensitive fields in production environments. You can block certain fields through the
$telescope->hidden()
method. - Task duplication record : Some tasks may be enqueued multiple times, resulting in multiple records in Telescope. Deduplication can be performed by task ID or custom identification.
Basically that's it. Just add a listening event and you can use Telescope to view the queued job. It is not complicated but easy to ignore. Under the default settings, tasks that cannot be seen with queued status, just make up for it manually.
The above is the detailed content of Monitoring Queued Jobs Telescope | Queue Inspection. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

InLaravel,policiesorganizeauthorizationlogicformodelactions.1.Policiesareclasseswithmethodslikeview,create,update,anddeletethatreturntrueorfalsebasedonuserpermissions.2.Toregisterapolicy,mapthemodeltoitspolicyinthe$policiesarrayofAuthServiceProvider.

Yes,youcaninstallLaravelonanyoperatingsystembyfollowingthesesteps:1.InstallPHPandrequiredextensionslikembstring,openssl,andxmlusingtoolslikeXAMPPonWindows,HomebrewonmacOS,oraptonLinux;2.InstallComposer,usinganinstalleronWindowsorterminalcommandsonmac

The main role of the controller in Laravel is to process HTTP requests and return responses to keep the code neat and maintainable. By concentrating the relevant request logic into a class, the controller makes the routing file simpler, such as putting user profile display, editing and deletion operations in different methods of UserController. The creation of a controller can be implemented through the Artisan command phpartisanmake:controllerUserController, while the resource controller is generated using the --resource option, covering methods for standard CRUD operations. Then you need to bind the controller in the route, such as Route::get('/user/{id

Laravel allows custom authentication views and logic by overriding the default stub and controller. 1. To customize the authentication view, use the command phpartisanvendor:publish-tag=laravel-auth to copy the default Blade template to the resources/views/auth directory and modify it, such as adding the "Terms of Service" check box. 2. To modify the authentication logic, you need to adjust the methods in RegisterController, LoginController and ResetPasswordController, such as updating the validator() method to verify the added field, or rewriting r

Laravelprovidesrobusttoolsforvalidatingformdata.1.Basicvalidationcanbedoneusingthevalidate()methodincontrollers,ensuringfieldsmeetcriterialikerequired,maxlength,oruniquevalues.2.Forcomplexscenarios,formrequestsencapsulatevalidationlogicintodedicatedc

Selectingonlyneededcolumnsimprovesperformancebyreducingresourceusage.1.Fetchingallcolumnsincreasesmemory,network,andprocessingoverhead.2.Unnecessarydataretrievalpreventseffectiveindexuse,raisesdiskI/O,andslowsqueryexecution.3.Tooptimize,identifyrequi

InLaravelBladetemplates,use{{{...}}}todisplayrawHTML.Bladeescapescontentwithin{{...}}usinghtmlspecialchars()topreventXSSattacks.However,triplebracesbypassescaping,renderingHTMLas-is.Thisshouldbeusedsparinglyandonlywithfullytrusteddata.Acceptablecases

TomockdependencieseffectivelyinLaravel,usedependencyinjectionforservices,shouldReceive()forfacades,andMockeryforcomplexcases.1.Forinjectedservices,use$this->instance()toreplacetherealclasswithamock.2.ForfacadeslikeMailorCache,useshouldReceive()tod
