|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace FriendsOfOpenTelemetry\OpenTelemetryBundle\Tests\Functional\Instrumentation\HttpKernel; |
| 4 | + |
| 5 | +use App\Kernel; |
| 6 | +use FriendsOfOpenTelemetry\OpenTelemetryBundle\Tests\Functional\TracingTestCaseTrait; |
| 7 | +use OpenTelemetry\SDK\Trace\StatusData; |
| 8 | +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
| 9 | +use Symfony\Component\HttpFoundation\Response; |
| 10 | +use Zalas\PHPUnit\Globals\Attribute\Env; |
| 11 | + |
| 12 | +#[Env('KERNEL_CLASS', Kernel::class)] |
| 13 | +#[Env('APP_ENV', 'empty_excludes')] |
| 14 | +class HttpKernelEmptyExcludesTracingTest extends WebTestCase |
| 15 | +{ |
| 16 | + use TracingTestCaseTrait; |
| 17 | + |
| 18 | + public function testSuccess(): void |
| 19 | + { |
| 20 | + $client = static::createClient(); |
| 21 | + $client->request('GET', '/auto-traceable'); |
| 22 | + |
| 23 | + static::assertResponseIsSuccessful(); |
| 24 | + static::assertSame('{"status":"ok"}', $client->getResponse()->getContent()); |
| 25 | + |
| 26 | + self::assertSpansCount(1); |
| 27 | + |
| 28 | + $mainSpan = self::getSpans()[0]; |
| 29 | + self::assertSpanName($mainSpan, 'app_traceable_autotraceable_index'); |
| 30 | + self::assertSpanStatus($mainSpan, StatusData::ok()); |
| 31 | + self::assertSpanAttributes($mainSpan, [ |
| 32 | + 'url.full' => 'http://localhost/auto-traceable', |
| 33 | + 'http.request.method' => 'GET', |
| 34 | + 'url.path' => '/auto-traceable', |
| 35 | + 'symfony.kernel.http.host' => 'localhost', |
| 36 | + 'url.scheme' => 'http', |
| 37 | + 'network.protocol.version' => '1.1', |
| 38 | + 'user_agent.original' => 'Symfony BrowserKit', |
| 39 | + 'network.peer.address' => '127.0.0.1', |
| 40 | + 'symfony.kernel.net.peer_ip' => '127.0.0.1', |
| 41 | + 'server.address' => 'localhost', |
| 42 | + 'server.port' => 80, |
| 43 | + 'http.route' => 'app_traceable_autotraceable_index', |
| 44 | + 'http.response.status_code' => Response::HTTP_OK, |
| 45 | + ]); |
| 46 | + self::assertSpanEventsCount($mainSpan, 0); |
| 47 | + } |
| 48 | +} |
0 commit comments