From 64852f8ce108dd9938329e7f78ceeac02a73cbd9 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Sun, 4 Jan 2026 17:27:21 +0000 Subject: [PATCH 1/2] feat: span actions --- composer.lock | 8 ++++---- src/DNS/Server.php | 2 +- tests/resources/server.php | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index d249beb..a189edd 100644 --- a/composer.lock +++ b/composer.lock @@ -2039,12 +2039,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/span.git", - "reference": "3af4ad7dc38a1da2e5fb4e47f296684fb18f8aae" + "reference": "93fe5c9febd9be698c044c69f92d35b721ccfb29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/span/zipball/3af4ad7dc38a1da2e5fb4e47f296684fb18f8aae", - "reference": "3af4ad7dc38a1da2e5fb4e47f296684fb18f8aae", + "url": "https://api.github.com/repos/utopia-php/span/zipball/93fe5c9febd9be698c044c69f92d35b721ccfb29", + "reference": "93fe5c9febd9be698c044c69f92d35b721ccfb29", "shasum": "" }, "require": { @@ -2093,7 +2093,7 @@ "source": "https://github.com/utopia-php/span/tree/main", "issues": "https://github.com/utopia-php/span/issues" }, - "time": "2025-12-31T11:11:21+00:00" + "time": "2026-01-04T17:14:48+00:00" }, { "name": "utopia-php/telemetry", diff --git a/src/DNS/Server.php b/src/DNS/Server.php index d5f1cc3..08962f2 100644 --- a/src/DNS/Server.php +++ b/src/DNS/Server.php @@ -164,7 +164,7 @@ protected function handleError(Throwable $error): void */ protected function onPacket(string $buffer, string $ip, int $port): string { - $span = Span::init(); + $span = Span::init('dns.packet'); $span->set('client.ip', $ip); $question = null; diff --git a/tests/resources/server.php b/tests/resources/server.php index b6e6d6a..ff63108 100644 --- a/tests/resources/server.php +++ b/tests/resources/server.php @@ -60,8 +60,7 @@ $dns->setDebug(false); $dns->onWorkerStart(function (Server $server, int $workerId) { - $span = Span::init(); - $span->set('action', 'dns.worker.start'); + $span = Span::init('dns.worker.start'); $span->set('worker.id', $workerId); $span->finish(); }); From 46c84a65a634947e667e8faf822c531f8feb54d3 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Sun, 4 Jan 2026 17:27:36 +0000 Subject: [PATCH 2/2] feat: worker control --- composer.lock | 8 ++++---- src/DNS/Adapter/Swoole.php | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index a189edd..cef88c5 100644 --- a/composer.lock +++ b/composer.lock @@ -2039,12 +2039,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/span.git", - "reference": "93fe5c9febd9be698c044c69f92d35b721ccfb29" + "reference": "849d22e409fda7013f946f9eee901a112dd5f27b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/span/zipball/93fe5c9febd9be698c044c69f92d35b721ccfb29", - "reference": "93fe5c9febd9be698c044c69f92d35b721ccfb29", + "url": "https://api.github.com/repos/utopia-php/span/zipball/849d22e409fda7013f946f9eee901a112dd5f27b", + "reference": "849d22e409fda7013f946f9eee901a112dd5f27b", "shasum": "" }, "require": { @@ -2093,7 +2093,7 @@ "source": "https://github.com/utopia-php/span/tree/main", "issues": "https://github.com/utopia-php/span/issues" }, - "time": "2026-01-04T17:14:48+00:00" + "time": "2026-01-04T17:31:38+00:00" }, { "name": "utopia-php/telemetry", diff --git a/src/DNS/Adapter/Swoole.php b/src/DNS/Adapter/Swoole.php index 6f76281..b806f86 100644 --- a/src/DNS/Adapter/Swoole.php +++ b/src/DNS/Adapter/Swoole.php @@ -15,12 +15,20 @@ class Swoole extends Adapter protected string $host; protected int $port; + protected int $numWorkers; + protected int $maxCoroutines; - public function __construct(string $host = '0.0.0.0', int $port = 53) + public function __construct(string $host = '0.0.0.0', int $port = 53, int $numWorkers = 1, int $maxCoroutines = 3000) { $this->host = $host; $this->port = $port; + $this->numWorkers = $numWorkers; + $this->maxCoroutines = $maxCoroutines; $this->server = new Server($this->host, $this->port, SWOOLE_PROCESS, SWOOLE_SOCK_UDP); + $this->server->set([ + 'worker_num' => $this->numWorkers, + 'max_coroutine' => $this->maxCoroutines, + ]); } /**