File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212namespace FriendsOfHyperf \Sentry \Metrics \Listener ;
1313
14+ use FriendsOfHyperf \Sentry \Feature ;
1415use FriendsOfHyperf \Sentry \Metrics \CoroutineServerStats ;
1516use FriendsOfHyperf \Sentry \Metrics \Timer ;
1617use Hyperf \Engine \Coroutine as Co ;
2223
2324class RequestWatcher implements ListenerInterface
2425{
25- public function __construct (protected CoroutineServerStats $ stats )
26- {
26+ public function __construct (
27+ protected CoroutineServerStats $ stats ,
28+ protected Feature $ feature ,
29+ ) {
2730 }
2831
2932 public function listen (): array
@@ -38,6 +41,10 @@ public function listen(): array
3841
3942 public function process (object $ event ): void
4043 {
44+ if (! $ this ->feature ->isMetricsEnabled ()) {
45+ return ;
46+ }
47+
4148 if ($ event instanceof HttpEvent \RequestReceived || $ event instanceof RpcEvent \RequestReceived) {
4249 ++$ this ->stats ->accept_count ;
4350 ++$ this ->stats ->request_count ;
You can’t perform that action at this time.
0 commit comments