Skip to content

Commit 6c664cc

Browse files
Copilothuangdijia
andauthored
fix(telescope): register RequestHandledListener and SetRequestLifecycleListener in ConfigProvider (#1043)
* Initial plan * fix(telescope): auto-register RequestHandledListener and SetRequestLifecycleListener The listeners were missing from ConfigProvider causing exceptions and non-200 status codes to not be captured after upgrading to v3.1.76. Users had to manually add these listeners which was error-prone. Changes: - Add RequestHandledListener and SetRequestLifecycleListener to ConfigProvider - Update documentation to reflect automatic listener registration - Add test to verify listeners are properly registered Co-authored-by: huangdijia <8337659+huangdijia@users.noreply.github.com> * fix(telescope): 移除类名中的反斜杠以简化代码 * 删除 ConfigProviderTest.php 测试文件 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: huangdijia <8337659+huangdijia@users.noreply.github.com>
1 parent 8d375df commit 6c664cc

File tree

4 files changed

+20
-124
lines changed

4 files changed

+20
-124
lines changed

en/components/telescope.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,11 @@ php bin/hyperf.php migrate
3434

3535
## Usage
3636

37-
> Choose either the listener or middleware
37+
### Middleware (Optional for gRPC)
3838

39-
### Request Listener
39+
Add the middleware in the `config/autoload/middlewares.php` configuration file
4040

41-
Add the listener in the `config/autoload/listeners.php` configuration file
42-
43-
```php
44-
<?php
45-
46-
return [
47-
FriendsOfHyperf\Telescope\Listener\RequestHandledListener::class,
48-
FriendsOfHyperf\Telescope\Listener\SetRequestLifecycleListener::class,
49-
];
50-
51-
```
52-
53-
### Middleware
54-
55-
Add the global middleware in the `config/autoload/middlewares.php` configuration file
56-
57-
To record HTTP requests, use the `http` middleware
58-
59-
```php
60-
<?php
61-
62-
return [
63-
'http' => [
64-
FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class,
65-
],
66-
];
67-
```
68-
69-
To record gRPC requests, use the `grpc` middleware
41+
To enable additional gRPC functionality, use the `grpc` middleware
7042

7143
```php
7244
<?php
@@ -78,6 +50,8 @@ return [
7850
];
7951
```
8052

53+
> Note: Request tracking is automatically enabled via the RequestHandledListener. The TelescopeMiddleware is only needed for additional gRPC-specific functionality.
54+
8155
## View Dashboard
8256

8357
`http://127.0.0.1:9501/telescope`

zh-cn/components/telescope.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,11 @@ php bin/hyperf.php migrate
3434

3535
## 使用
3636

37-
> 监听器和中间件,二选一即可
37+
### 中间件(可选,仅用于gRPC)
3838

39-
### 请求监听器
39+
`config/autoload/middlewares.php`配置文件加上中间件
4040

41-
`config/autoload/listeners.php`配置文件添加监听器
42-
43-
```php
44-
<?php
45-
46-
return [
47-
FriendsOfHyperf\Telescope\Listener\RequestHandledListener::class,
48-
FriendsOfHyperf\Telescope\Listener\SetRequestLifecycleListener::class,
49-
];
50-
51-
```
52-
53-
### 中间件
54-
55-
`config/autoload/middlewares.php`配置文件加上全局中间件
56-
57-
如需记录http请求,请使用`http`中间件
58-
59-
```php
60-
<?php
61-
62-
return [
63-
'http' => [
64-
FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class,
65-
],
66-
];
67-
```
68-
69-
如需记录gRPC请求,请使用`grpc`中间件
41+
如需gRPC的额外功能,请使用`grpc`中间件
7042

7143
```php
7244
<?php
@@ -78,6 +50,8 @@ return [
7850
];
7951
```
8052

53+
> 注意: 请求跟踪功能已通过 RequestHandledListener 自动启用。TelescopeMiddleware 仅用于 gRPC 的额外功能。
54+
8155
## 查看仪表板
8256

8357
`http://127.0.0.1:9501/telescope`

zh-hk/components/telescope.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,11 @@ php bin/hyperf.php migrate
3434

3535
## 使用
3636

37-
> 監聽器和中間件,二選一即可
37+
### 中間件(可選,僅用於gRPC)
3838

39-
### 請求監聽器
39+
`config/autoload/middlewares.php`配置文件加上中間件
4040

41-
`config/autoload/listeners.php`配置文件添加監聽器
42-
43-
```php
44-
<?php
45-
46-
return [
47-
FriendsOfHyperf\Telescope\Listener\RequestHandledListener::class,
48-
FriendsOfHyperf\Telescope\Listener\SetRequestLifecycleListener::class,
49-
];
50-
51-
```
52-
53-
### 中間件
54-
55-
`config/autoload/middlewares.php`配置文件加上全局中間件
56-
57-
如需記錄http請求,請使用`http`中間件
58-
59-
```php
60-
<?php
61-
62-
return [
63-
'http' => [
64-
FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class,
65-
],
66-
];
67-
```
68-
69-
如需記錄gRPC請求,請使用`grpc`中間件
41+
如需gRPC的額外功能,請使用`grpc`中間件
7042

7143
```php
7244
<?php
@@ -78,6 +50,8 @@ return [
7850
];
7951
```
8052

53+
> 注意: 請求追蹤功能已通過 RequestHandledListener 自動啟用。TelescopeMiddleware 僅用於 gRPC 的額外功能。
54+
8155
## 查看儀表板
8256

8357
`http://127.0.0.1:9501/telescope`

zh-tw/components/telescope.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,11 @@ php bin/hyperf.php migrate
3434

3535
## 使用
3636

37-
> 監聽器和中介軟體,二選一即可
37+
### 中介軟體(可選,僅用於gRPC)
3838

39-
### 請求監聽器
39+
`config/autoload/middlewares.php`配置檔案加上中介軟體
4040

41-
`config/autoload/listeners.php`配置檔案新增監聽器
42-
43-
```php
44-
<?php
45-
46-
return [
47-
FriendsOfHyperf\Telescope\Listener\RequestHandledListener::class,
48-
FriendsOfHyperf\Telescope\Listener\SetRequestLifecycleListener::class,
49-
];
50-
51-
```
52-
53-
### 中介軟體
54-
55-
`config/autoload/middlewares.php`配置檔案加上全域性中介軟體
56-
57-
如需記錄http請求,請使用`http`中介軟體
58-
59-
```php
60-
<?php
61-
62-
return [
63-
'http' => [
64-
FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class,
65-
],
66-
];
67-
```
68-
69-
如需記錄gRPC請求,請使用`grpc`中介軟體
41+
如需gRPC的額外功能,請使用`grpc`中介軟體
7042

7143
```php
7244
<?php
@@ -78,6 +50,8 @@ return [
7850
];
7951
```
8052

53+
> 注意: 請求追蹤功能已透過 RequestHandledListener 自動啟用。TelescopeMiddleware 僅用於 gRPC 的額外功能。
54+
8155
## 檢視儀表板
8256

8357
`http://127.0.0.1:9501/telescope`

0 commit comments

Comments
 (0)