Skip to content

Commit ccf47b6

Browse files
committed
fix(sentry): add feature dependency to RequestWatcher for metrics control
1 parent 105ae92 commit ccf47b6

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/Metrics/Listener/RequestWatcher.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace FriendsOfHyperf\Sentry\Metrics\Listener;
1313

14+
use FriendsOfHyperf\Sentry\Feature;
1415
use FriendsOfHyperf\Sentry\Metrics\CoroutineServerStats;
1516
use FriendsOfHyperf\Sentry\Metrics\Timer;
1617
use Hyperf\Engine\Coroutine as Co;
@@ -22,8 +23,10 @@
2223

2324
class 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;

0 commit comments

Comments
 (0)