55use OpenTelemetry \Contrib \Otlp \ContentTypes ;
66use PHPUnit \Framework \Attributes \RequiresPhpExtension ;
77use PHPUnit \Framework \TestCase ;
8- use Utopia \Telemetry \Adapter \OpenTelemetry \Swoole \ Transport ;
8+ use Utopia \Telemetry \Adapter \OpenTelemetry \Transport \ Swoole ;
99use Utopia \Telemetry \Exception ;
1010
1111use function Swoole \Coroutine \run ;
@@ -44,21 +44,21 @@ private function runInCoroutine(callable $callback): mixed
4444
4545 public function testConstructorParsesEndpointCorrectly (): void
4646 {
47- $ transport = new Transport ('https://otel.example.com:4318/v1/metrics?foo=bar ' );
47+ $ transport = new Swoole ('https://otel.example.com:4318/v1/metrics?foo=bar ' );
4848
4949 $ this ->assertEquals (ContentTypes::PROTOBUF , $ transport ->contentType ());
5050 }
5151
5252 public function testConstructorWithHttpEndpoint (): void
5353 {
54- $ transport = new Transport ('http://localhost:4318/v1/metrics ' );
54+ $ transport = new Swoole ('http://localhost:4318/v1/metrics ' );
5555
5656 $ this ->assertEquals (ContentTypes::PROTOBUF , $ transport ->contentType ());
5757 }
5858
5959 public function testConstructorWithCustomContentType (): void
6060 {
61- $ transport = new Transport (
61+ $ transport = new Swoole (
6262 'http://localhost:4318/v1/metrics ' ,
6363 ContentTypes::JSON
6464 );
@@ -68,7 +68,7 @@ public function testConstructorWithCustomContentType(): void
6868
6969 public function testConstructorWithCustomHeaders (): void
7070 {
71- $ transport = new Transport (
71+ $ transport = new Swoole (
7272 'http://localhost:4318/v1/metrics ' ,
7373 ContentTypes::PROTOBUF ,
7474 ['Authorization ' => 'Bearer token123 ' ]
@@ -79,7 +79,7 @@ public function testConstructorWithCustomHeaders(): void
7979
8080 public function testConstructorWithCustomTimeout (): void
8181 {
82- $ transport = new Transport (
82+ $ transport = new Swoole (
8383 'http://localhost:4318/v1/metrics ' ,
8484 ContentTypes::PROTOBUF ,
8585 [],
@@ -91,7 +91,7 @@ public function testConstructorWithCustomTimeout(): void
9191
9292 public function testConstructorWithCustomPoolSize (): void
9393 {
94- $ transport = new Transport (
94+ $ transport = new Swoole (
9595 'http://localhost:4318/v1/metrics ' ,
9696 ContentTypes::PROTOBUF ,
9797 [],
@@ -104,7 +104,7 @@ public function testConstructorWithCustomPoolSize(): void
104104
105105 public function testConstructorWithCustomSocketBufferSize (): void
106106 {
107- $ transport = new Transport (
107+ $ transport = new Swoole (
108108 'http://localhost:4318/v1/metrics ' ,
109109 ContentTypes::PROTOBUF ,
110110 [],
@@ -119,7 +119,7 @@ public function testConstructorWithCustomSocketBufferSize(): void
119119 public function testShutdownReturnsTrue (): void
120120 {
121121 $ this ->runInCoroutine (function () {
122- $ transport = new Transport ('http://localhost:4318/v1/metrics ' );
122+ $ transport = new Swoole ('http://localhost:4318/v1/metrics ' );
123123
124124 $ result = $ transport ->shutdown ();
125125
@@ -130,7 +130,7 @@ public function testShutdownReturnsTrue(): void
130130 public function testForceFlushReturnsTrue (): void
131131 {
132132 $ this ->runInCoroutine (function () {
133- $ transport = new Transport ('http://localhost:4318/v1/metrics ' );
133+ $ transport = new Swoole ('http://localhost:4318/v1/metrics ' );
134134
135135 $ result = $ transport ->forceFlush ();
136136
@@ -141,22 +141,22 @@ public function testForceFlushReturnsTrue(): void
141141 public function testSendAfterShutdownReturnsError (): void
142142 {
143143 $ this ->runInCoroutine (function () {
144- $ transport = new Transport ('http://localhost:4318/v1/metrics ' );
144+ $ transport = new Swoole ('http://localhost:4318/v1/metrics ' );
145145
146146 $ transport ->shutdown ();
147147
148148 $ future = $ transport ->send ('test payload ' );
149149
150150 $ this ->expectException (Exception::class);
151- $ this ->expectExceptionMessage ('Transport has been shut down ' );
151+ $ this ->expectExceptionMessage ('Swoole has been shut down ' );
152152 $ future ->await ();
153153 });
154154 }
155155
156156 public function testMultipleShutdownsAreSafe (): void
157157 {
158158 $ this ->runInCoroutine (function () {
159- $ transport = new Transport ('http://localhost:4318/v1/metrics ' );
159+ $ transport = new Swoole ('http://localhost:4318/v1/metrics ' );
160160
161161 $ result1 = $ transport ->shutdown ();
162162 $ result2 = $ transport ->shutdown ();
@@ -168,37 +168,37 @@ public function testMultipleShutdownsAreSafe(): void
168168
169169 public function testEndpointWithQueryString (): void
170170 {
171- $ transport = new Transport ('http://localhost:4318/v1/metrics?api_key=secret&env=test ' );
171+ $ transport = new Swoole ('http://localhost:4318/v1/metrics?api_key=secret&env=test ' );
172172
173173 $ this ->assertEquals (ContentTypes::PROTOBUF , $ transport ->contentType ());
174174 }
175175
176176 public function testEndpointDefaultsToLocalhost (): void
177177 {
178178 // Malformed URL should still create transport (defaults to localhost)
179- $ transport = new Transport ('http:///v1/metrics ' );
179+ $ transport = new Swoole ('http:///v1/metrics ' );
180180
181181 $ this ->assertEquals (ContentTypes::PROTOBUF , $ transport ->contentType ());
182182 }
183183
184184 public function testDefaultPortForHttp (): void
185185 {
186- $ transport = new Transport ('http://example.com/v1/metrics ' );
186+ $ transport = new Swoole ('http://example.com/v1/metrics ' );
187187
188188 $ this ->assertEquals (ContentTypes::PROTOBUF , $ transport ->contentType ());
189189 }
190190
191191 public function testDefaultPortForHttps (): void
192192 {
193- $ transport = new Transport ('https://example.com/v1/metrics ' );
193+ $ transport = new Swoole ('https://example.com/v1/metrics ' );
194194
195195 $ this ->assertEquals (ContentTypes::PROTOBUF , $ transport ->contentType ());
196196 }
197197
198198 public function testContentTypeMatchesConstructor (): void
199199 {
200- $ jsonTransport = new Transport ('http://localhost:4318 ' , ContentTypes::JSON );
201- $ protobufTransport = new Transport ('http://localhost:4318 ' , ContentTypes::PROTOBUF );
200+ $ jsonTransport = new Swoole ('http://localhost:4318 ' , ContentTypes::JSON );
201+ $ protobufTransport = new Swoole ('http://localhost:4318 ' , ContentTypes::PROTOBUF );
202202
203203 $ this ->assertEquals (ContentTypes::JSON , $ jsonTransport ->contentType ());
204204 $ this ->assertEquals (ContentTypes::PROTOBUF , $ protobufTransport ->contentType ());
0 commit comments