1313namespace Hyperf \Metric \Listener ;
1414
1515use Hyperf \Contract \ConfigInterface ;
16- use Hyperf \Coordinator \Constants ;
17- use Hyperf \Coordinator \CoordinatorManager ;
1816use Hyperf \Coordinator \Timer ;
19- use Hyperf \Coroutine \Coroutine ;
2017use Hyperf \Event \Contract \ListenerInterface ;
2118use Hyperf \Framework \Event \BeforeWorkerStart ;
2219use Hyperf \Metric \Contract \MetricFactoryInterface ;
@@ -125,7 +122,7 @@ public function process(object $event): void
125122 );
126123
127124 $ timerInterval = $ this ->config ->get ('metric.default_metric_interval ' , 5 );
128- $ timerId = $ this ->timer ->tick ($ timerInterval , function () use ($ metrics ) {
125+ $ this ->timer ->tick ($ timerInterval , function () use ($ metrics ) {
129126 $ server = $ this ->container ->get (Server::class);
130127 $ serverStats = $ server ->stats ();
131128 $ this ->trySet ('gc_ ' , $ metrics , gc_status ());
@@ -136,11 +133,6 @@ public function process(object $event): void
136133 $ metrics ['memory_usage ' ]->set (memory_get_usage ());
137134 $ metrics ['memory_peak_usage ' ]->set (memory_get_peak_usage ());
138135 });
139- // Clean up timer on worker exit;
140- Coroutine::create (function () use ($ timerId ) {
141- CoordinatorManager::until (Constants::WORKER_EXIT )->yield ();
142- $ this ->timer ->clear ($ timerId );
143- });
144136 }
145137
146138 private function shouldFireMetricFactoryReadyEvent (int $ workerId ): bool
0 commit comments