friendsofhyperf / telescope
hyperf 框架的优雅调试助手。
资助包维护!
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.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-09-25 00:31:38 UTC
README
hyperf 框架的优雅调试助手。
功能
- request
- exception
- sql
- grpc 服务器/客户端
- redis
- 日志
- 命令
- 事件
- guzzle
- 缓存
- rpc 服务器/客户端
安装
composer require friendsofhyperf/telescope:~3.1.0
发布
php bin/hyperf.php vendor:publish friendsofhyperf/telescope
迁移
php bin/hyperf.php migrate
添加监听器
<?php // config/autoload/listeners.php return [ FriendsOfHyperf\Telescope\Listener\RequestHandledListener::class, ];
添加中间件
<?php // config/autoload/middlewares.php return [ 'grpc' => [ FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class, ], ];
TelescopeMiddleware 或 RequestHandledListener,您可以选择其中之一。
添加环境变量
# 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
访问
http://127.0.0.1:9509/telescope/requests
标签
您可能希望为条目附加自定义标签。为此,您可以使用 Telescope::tag
方法。
过滤
您可能只想在特定条件下记录条目。为此,您可以使用 Telescope::filter
方法。
示例
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; }); } }
您也可以在中间件中这样做。