friendsofhyperf / telescope
An elegant debug assistant for the hyperf framework.
Fund package maintenance!
huangdijia
hdj.me/sponsors
Requires
- php: >=8.1
- hyperf/command: ~3.1.0
- hyperf/event: ~3.1.0
- hyperf/framework: ~3.1.0
- hyperf/support: ~3.1.0
- hyperf/view-engine: ~3.1.0
- nesbot/carbon: ^2.71 || ^3.0
- ramsey/uuid: ^4.7
Suggests
- guzzlehttp/guzzle: Required to use Guzzle annotation.(^6.0|^7.0)
- hyperf/command: Required to use Command annotation.(~3.1.0)
- hyperf/database: Required to use Database annotation.(~3.1.0)
- hyperf/db-connection: Required to use db-connection annotation.(~3.1.0)
- hyperf/dispatcher: Required to use BootApplication event.(~3.1.0)
- hyperf/event: Required to use Event annotation.(~3.1.0)
- hyperf/http-message: Required to use http-message annotation.(~3.1.0)
- dev-main / 3.1.x-dev
- v3.1.46.5
- v3.1.46.4
- v3.1.46.3
- v3.1.46.2
- v3.1.46.1
- v3.1.45
- v3.1.44
- v3.1.42
- v3.1.41
- v3.1.31
- v3.1.29
- v3.1.28.2
- v3.1.27
- v3.1.24
- v3.1.20
- v3.1.18
- v3.1.17
- v3.1.16
- v3.1.15
- v3.1.13
- v3.1.11
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.0
- v3.1.0-rc.22
- v3.1.0-rc.21
- v3.1.0-rc.20
- v3.1.0-rc.19
- v3.1.0-rc.18
- v3.1.0-rc.1
- 3.0.x-dev
- v3.0.121
- v3.0.120
- v3.0.118
- v3.0.117
- v3.0.113
- v3.0.112
- v3.0.111
- v3.0.110
- v3.0.109
- v3.0.105
- v3.0.104
- v3.0.103
- v3.0.102
- v3.0.1
- v3.0.0
This package is auto-updated.
Last update: 2024-11-22 10:31:07 UTC
README
An elegant debug assistant for the hyperf framework.
Functions
- request
- exception
- sql
- grpc server/client
- redis
- log
- command
- event
- guzzle
- cache
- rpc server/client
Installation
composer require friendsofhyperf/telescope:~3.1.0
Publish
php bin/hyperf.php vendor:publish friendsofhyperf/telescope
Migrate
php bin/hyperf.php migrate
Add Listener
<?php // config/autoload/listeners.php return [ FriendsOfHyperf\Telescope\Listener\RequestHandledListener::class, ];
Add Middleware
<?php // config/autoload/middlewares.php return [ 'grpc' => [ FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class, ], ];
TelescopeMiddleware or RequestHandledListener, you can choose one of them.
Add env
# telescope TELESCOPE_DB_CONNECTION=default TELESCOPE_ENABLE_REQUEST=true TELESCOPE_ENABLE_COMMAND=true TELESCOPE_ENABLE_GRPC=true TELESCOPE_ENABLE_LOG=true TELESCOPE_ENABLE_REDIS=true TELESCOPE_ENABLE_EVENT=true TELESCOPE_ENABLE_EXCEPTION=true TELESCOPE_ENABLE_JOB=true TELESCOPE_ENABLE_DB=true TELESCOPE_ENABLE_GUZZLE=true TELESCOPE_ENABLE_CACHE=true TELESCOPE_ENABLE_RPC=true TELESCOPE_SERVER_ENABLE=true
Visit
http://127.0.0.1:9509/telescope/requests
Tagging
you may want to attach your own custom tags to entries. To accomplish this, you may use the Telescope::tag
method.
Filtering
You may only want to record entries under certain special conditions. To achieve this, you may use the Telescope::filter
method.
Example
use FriendsOfHyperf\Telescope\Telescope; use Hyperf\Event\Contract\ListenerInterface; use Hyperf\Framework\Event\BootApplication; use FriendsOfHyperf\Telescope\IncomingEntry; class TelescopeInitListener implements ListenerInterface { public function listen(): array { return [ BootApplication::class, ]; } public function process(object $event): void { // attach your own custom tags Telescope::tag(function (IncomingEntry $entry) { if ($entry->type === 'request') { return [ 'status:' . $entry->content['response_status'], 'uri:'. $entry->content['uri'], ]; } }); // filter entry Telescope::filter(function (IncomingEntry $entry): bool { if ($entry->type === 'request'){ if ($entry->content['uri'] == 'xxxx') { return false; } } return true; }); } }
You can also do this in middleware.