From 9dde3bfd84e55f088571cb11c733a2f0dcf219d2 Mon Sep 17 00:00:00 2001 From: Julian Date: Wed, 12 Jun 2024 17:07:15 +0200 Subject: [PATCH 1/7] Add http.route tag to SymfonyIntegration.php --- .../src/docker/php/build_dev_php.sh | 19 ++++++++- .../config/packages/test/framework.yaml | 2 +- .../src/Controller/HomeController.php | 8 ++-- docker-compose.yml | 2 +- .../Symfony/SymfonyIntegration.php | 40 ++++++++++++++++++- tests/Common/TracerTestTrait.php | 2 +- tests/Common/WebFrameworkTestCase.php | 9 +++++ .../Controller/CommonScenariosController.php | 10 ++--- .../Symfony/V3_0/CommonScenariosTest.php | 3 ++ .../Symfony/V3_0/TraceSearchConfigTest.php | 1 + .../Symfony/V3_3/CommonScenariosTest.php | 3 ++ .../Symfony/V3_3/TraceSearchConfigTest.php | 1 + .../V3_4/AutofinishedTracesSymfony34Test.php | 1 + .../Symfony/V3_4/CommonScenariosTest.php | 3 ++ .../Symfony/V3_4/TemplateEnginesTest.php | 1 + .../Symfony/V3_4/TraceSearchConfigTest.php | 1 + .../Symfony/V4_0/CommonScenariosTest.php | 3 ++ .../Symfony/V4_0/TraceSearchConfigTest.php | 1 + .../Symfony/V4_2/CommonScenariosTest.php | 3 ++ .../Symfony/V4_2/TraceSearchConfigTest.php | 1 + .../Symfony/V4_4/CommonScenariosTest.php | 3 ++ .../Symfony/V4_4/TraceSearchConfigTest.php | 1 + .../Symfony/V5_0/CommonScenariosTest.php | 3 ++ .../Symfony/V5_0/TraceSearchConfigTest.php | 1 + .../Symfony/V5_1/CommonScenariosTest.php | 3 ++ .../Symfony/V5_1/TraceSearchConfigTest.php | 1 + .../Symfony/V5_2/CommonScenariosTest.php | 3 ++ .../Symfony/V5_2/TraceSearchConfigTest.php | 1 + .../Symfony/V6_2/CommonScenariosTest.php | 3 ++ .../Symfony/V6_2/TraceSearchConfigTest.php | 1 + .../Symfony/V7_0/CommonScenariosTest.php | 3 ++ tests/composer.json | 1 + 32 files changed, 121 insertions(+), 17 deletions(-) diff --git a/appsec/tests/integration/src/docker/php/build_dev_php.sh b/appsec/tests/integration/src/docker/php/build_dev_php.sh index 4221002b61..ed6e1ed9c0 100755 --- a/appsec/tests/integration/src/docker/php/build_dev_php.sh +++ b/appsec/tests/integration/src/docker/php/build_dev_php.sh @@ -80,6 +80,21 @@ EOD chmod +x /tmp/apxs_wrapper } +function run_dsymutil { + if [[ $(uname) != Darwin ]] then + return + fi + local readonly dir=$1 exe= + find "$dir" -type f -exec test -x '{}' \; -print | while read -r exe; do + if ! grep -q '^#!' "$exe"; then + local readonly dSYM_DIR="${exe}.dSYM" + if [[ ! -d $dSYM_DIR ]]; then + dsymutil "$exe" + fi + fi + done +} + function get_xdebug_version { local -r version=$1 local readonly version_id=$(php_version_id $version) @@ -294,6 +309,7 @@ function build_php { make install-sapi || true make install-binaries install-headers install-modules install-programs install-build + run_dsymutil "$prefix_dir" rm -rf "$build_dir" cd - } @@ -462,11 +478,12 @@ function install_xdebug { "$php_prefix/bin/phpize" mkdir -p "$build_dir" cd "$build_dir" - "$xdebug_source_dir/configure" "--with-php-config=$php_prefix/bin/php-config" + CFLAGS="$CFLAGS -ggdb" "$xdebug_source_dir/configure" "--with-php-config=$php_prefix/bin/php-config" make -j make install cd - + run_dsymutil "$php_prefix/lib" rm -rf "$build_dir" } diff --git a/appsec/tests/integration/src/test/www/symfony62/config/packages/test/framework.yaml b/appsec/tests/integration/src/test/www/symfony62/config/packages/test/framework.yaml index d051c84008..ee44ae54c1 100644 --- a/appsec/tests/integration/src/test/www/symfony62/config/packages/test/framework.yaml +++ b/appsec/tests/integration/src/test/www/symfony62/config/packages/test/framework.yaml @@ -1,4 +1,4 @@ framework: test: true session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file diff --git a/appsec/tests/integration/src/test/www/symfony62/src/Controller/HomeController.php b/appsec/tests/integration/src/test/www/symfony62/src/Controller/HomeController.php index ba2f481df4..7fbe2fc90e 100644 --- a/appsec/tests/integration/src/test/www/symfony62/src/Controller/HomeController.php +++ b/appsec/tests/integration/src/test/www/symfony62/src/Controller/HomeController.php @@ -21,13 +21,11 @@ public function homeAction(Request $request) ); } - /** - * @Route("/dynamic-path/{param01}", name="dynamic-path") - */ - public function dynamicAction(Request $request) + #[Route("/dynamic-path/{param01}")] + public function dynamicAction(Request $request, string $param01) { return new Response( - 'Hi!' + "Hi $param01!" ); } } diff --git a/docker-compose.yml b/docker-compose.yml index 8e13a439f5..8472711f7f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -280,7 +280,7 @@ services: test-agent: image: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:latest ports: - - "127.0.0.1:9126:8126" + - "9126:9126" volumes: - ./tests/snapshots:/snapshots environment: diff --git a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php index c633513ec0..80668f9d9c 100644 --- a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php +++ b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php @@ -10,7 +10,9 @@ use DDTrace\Type; use DDTrace\Util\Normalizer; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Event\ControllerEvent; use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\Routing\Route; class SymfonyIntegration extends Integration { @@ -307,6 +309,42 @@ function ($This, $scope, $args) use ($integration) { } ); + \DDTrace\trace_method( + 'Symfony\Component\EventDispatcher\EventDispatcher', + 'dispatch', + function (SpanData $span, $args) { + $event = $args[0]; + + if (!($event instanceof ControllerEvent)) { + return; + } + + $request = $event->getRequest(); + $controller = $event->getController()[0]; + + if (!property_exists($controller, 'container')) { + return; + } + + $rc = new \ReflectionClass(get_class($controller)); + $container = $rc->getProperty('container'); + $container->setAccessible(true); + $container = $container->getValue($controller); + + $router = $container->get('router'); + $routeName = $request->attributes->get('_route'); + + $routeCollection = $router->getRouteCollection(); + /** @var Route $route */ + $route = $routeCollection->get($routeName); + if (!isset($route)) { + return; + } + $root_span = \DDTrace\root_span(); + $root_span->meta[Tag::HTTP_ROUTE] = $route->getPath(); + } + ); + $this->loadSymfony($this); return Integration::LOADED; @@ -394,7 +432,7 @@ function (SpanData $span, $args, $response) use ($integration) { $parameters = $request->get('_route_params'); if (!empty($parameters) && is_array($parameters) && - function_exists('\datadog\appsec\push_address')) { + function_exists('datadog\appsec\push_address')) { \datadog\appsec\push_address("server.request.path_params", $parameters); } diff --git a/tests/Common/TracerTestTrait.php b/tests/Common/TracerTestTrait.php index 3390ad9468..e783497351 100644 --- a/tests/Common/TracerTestTrait.php +++ b/tests/Common/TracerTestTrait.php @@ -310,7 +310,7 @@ public function tracesFromWebRequest($fn, $tracer = null, callable $until = null // Clearing existing dumped file $this->resetRequestDumper(); - // The we server has to be configured to send traces to the provided requests dumper. + // The web server has to be configured to send traces to the provided requests dumper. $fn($tracer); self::putEnv('DD_TRACE_SHUTDOWN_TIMEOUT'); diff --git a/tests/Common/WebFrameworkTestCase.php b/tests/Common/WebFrameworkTestCase.php index c1ae0bdadb..059e318607 100644 --- a/tests/Common/WebFrameworkTestCase.php +++ b/tests/Common/WebFrameworkTestCase.php @@ -141,9 +141,18 @@ protected static function getInis() // The following values should be made configurable from the outside. I could not get env XDEBUG_CONFIG // to work setting it both in docker-compose.yml and in `getEnvs()` above, but that should be the best // option. + 'xdebug.start_with_request' => 'yes', + + // 2 'xdebug.remote_enable' => 1, 'xdebug.remote_host' => 'host.docker.internal', 'xdebug.remote_autostart' => 1, + // 'xdebug.remote_log' => '/tmp/xdebug.log', + + // 3 + 'xdebug.mode' => 'develop,debug', + 'xdebug.client_host' => 'host.docker.internal', + // 'xdebug.log' => '/tmp/xdebug.log', ] + ($enableOpcache ? ["zend_extension" => "opcache.so"] : []); } diff --git a/tests/Frameworks/Symfony/Version_6_2/src/Controller/CommonScenariosController.php b/tests/Frameworks/Symfony/Version_6_2/src/Controller/CommonScenariosController.php index ec2777c2e4..3a631f694c 100644 --- a/tests/Frameworks/Symfony/Version_6_2/src/Controller/CommonScenariosController.php +++ b/tests/Frameworks/Symfony/Version_6_2/src/Controller/CommonScenariosController.php @@ -10,9 +10,7 @@ class CommonScenariosController extends AbstractController { - /** - * @Route("/simple", name="simple") - */ + #[Route("/simple", name:"simple")] public function simpleAction(Request $request) { // replace this example code with whatever you need @@ -21,9 +19,7 @@ public function simpleAction(Request $request) ); } - /** - * @Route("/simple_view", name="simple_view") - */ + #[Route("/simple_view", name:"simple_view")] public function simpleViewAction(Request $request) { // replace this example code with whatever you need @@ -43,9 +39,9 @@ public function dynamicWithOptionalsAction($param01, $param02) } /** - * @Route("/error", name="error") * @throws \Exception */ + #[Route("/error", name:"error")] public function errorAction(Request $request) { throw new \Exception('An exception occurred'); diff --git a/tests/Integrations/Symfony/V3_0/CommonScenariosTest.php b/tests/Integrations/Symfony/V3_0/CommonScenariosTest.php index 4f9d14068d..3e99d03780 100644 --- a/tests/Integrations/Symfony/V3_0/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V3_0/CommonScenariosTest.php @@ -42,6 +42,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -79,6 +80,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -125,6 +127,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V3_0/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V3_0/TraceSearchConfigTest.php index 82be10bfa6..bf934a5c46 100644 --- a/tests/Integrations/Symfony/V3_0/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V3_0/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V3_3/CommonScenariosTest.php b/tests/Integrations/Symfony/V3_3/CommonScenariosTest.php index 7e6d402ec9..ba0c97b767 100644 --- a/tests/Integrations/Symfony/V3_3/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V3_3/CommonScenariosTest.php @@ -42,6 +42,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -80,6 +81,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -127,6 +129,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V3_3/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V3_3/TraceSearchConfigTest.php index 2c9478e5a3..8763eda8e4 100644 --- a/tests/Integrations/Symfony/V3_3/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V3_3/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V3_4/AutofinishedTracesSymfony34Test.php b/tests/Integrations/Symfony/V3_4/AutofinishedTracesSymfony34Test.php index 5e69751943..1dfb248b71 100644 --- a/tests/Integrations/Symfony/V3_4/AutofinishedTracesSymfony34Test.php +++ b/tests/Integrations/Symfony/V3_4/AutofinishedTracesSymfony34Test.php @@ -36,6 +36,7 @@ public function testEndpointThatExitsWithNoProcess() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\HomeController@actionBeingTerminatedByExit', 'symfony.route.name' => 'terminated_by_exit', + 'http.route' => '/terminated_by_exit', 'http.method' => 'GET', 'http.url' => 'http://localhost/terminated_by_exit', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V3_4/CommonScenariosTest.php b/tests/Integrations/Symfony/V3_4/CommonScenariosTest.php index 4973645565..3f64e90ea4 100644 --- a/tests/Integrations/Symfony/V3_4/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V3_4/CommonScenariosTest.php @@ -49,6 +49,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -87,6 +88,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -136,6 +138,7 @@ public function provideSpecs() ->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V3_4/TemplateEnginesTest.php b/tests/Integrations/Symfony/V3_4/TemplateEnginesTest.php index 910c479081..a0c8ddb38b 100644 --- a/tests/Integrations/Symfony/V3_4/TemplateEnginesTest.php +++ b/tests/Integrations/Symfony/V3_4/TemplateEnginesTest.php @@ -29,6 +29,7 @@ public function testAlternateTemplatingEngine() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\HomeController@indexAction', 'symfony.route.name' => 'alternate_templating', + 'http.route' => '/alternate_templating', 'http.method' => 'GET', 'http.url' => 'http://localhost/alternate_templating', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V3_4/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V3_4/TraceSearchConfigTest.php index b7ffd3eba3..7126d4b6ac 100644 --- a/tests/Integrations/Symfony/V3_4/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V3_4/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V4_0/CommonScenariosTest.php b/tests/Integrations/Symfony/V4_0/CommonScenariosTest.php index e93bc42506..bc00aa3442 100644 --- a/tests/Integrations/Symfony/V4_0/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V4_0/CommonScenariosTest.php @@ -50,6 +50,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -88,6 +89,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -135,6 +137,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V4_0/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V4_0/TraceSearchConfigTest.php index 1cacc0f82a..88dd8bf81d 100644 --- a/tests/Integrations/Symfony/V4_0/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V4_0/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V4_2/CommonScenariosTest.php b/tests/Integrations/Symfony/V4_2/CommonScenariosTest.php index f2a703c53d..c293613a34 100644 --- a/tests/Integrations/Symfony/V4_2/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V4_2/CommonScenariosTest.php @@ -50,6 +50,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -88,6 +89,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -135,6 +137,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V4_2/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V4_2/TraceSearchConfigTest.php index 5e7d684b29..77f9509044 100644 --- a/tests/Integrations/Symfony/V4_2/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V4_2/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V4_4/CommonScenariosTest.php b/tests/Integrations/Symfony/V4_4/CommonScenariosTest.php index 5ef29b708f..880e2730b5 100644 --- a/tests/Integrations/Symfony/V4_4/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V4_4/CommonScenariosTest.php @@ -50,6 +50,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -90,6 +91,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -137,6 +139,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V4_4/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V4_4/TraceSearchConfigTest.php index a751f93854..4bd9abad30 100644 --- a/tests/Integrations/Symfony/V4_4/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V4_4/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V5_0/CommonScenariosTest.php b/tests/Integrations/Symfony/V5_0/CommonScenariosTest.php index 4877a3df41..e96fe20b52 100644 --- a/tests/Integrations/Symfony/V5_0/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V5_0/CommonScenariosTest.php @@ -50,6 +50,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -90,6 +91,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -137,6 +139,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V5_0/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V5_0/TraceSearchConfigTest.php index 58e5e95683..e83b145a47 100644 --- a/tests/Integrations/Symfony/V5_0/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V5_0/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V5_1/CommonScenariosTest.php b/tests/Integrations/Symfony/V5_1/CommonScenariosTest.php index 4007c20974..0f57fe3dd6 100644 --- a/tests/Integrations/Symfony/V5_1/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V5_1/CommonScenariosTest.php @@ -50,6 +50,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -90,6 +91,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -137,6 +139,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V5_1/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V5_1/TraceSearchConfigTest.php index 9a6022439a..1cdde78ddd 100644 --- a/tests/Integrations/Symfony/V5_1/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V5_1/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V5_2/CommonScenariosTest.php b/tests/Integrations/Symfony/V5_2/CommonScenariosTest.php index 26e2a39be0..9bda41e4fd 100644 --- a/tests/Integrations/Symfony/V5_2/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V5_2/CommonScenariosTest.php @@ -50,6 +50,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -88,6 +89,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -133,6 +135,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V5_2/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V5_2/TraceSearchConfigTest.php index 2e391cbb73..86584cfbda 100644 --- a/tests/Integrations/Symfony/V5_2/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V5_2/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V6_2/CommonScenariosTest.php b/tests/Integrations/Symfony/V6_2/CommonScenariosTest.php index ec2400813c..605db929c0 100644 --- a/tests/Integrations/Symfony/V6_2/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V6_2/CommonScenariosTest.php @@ -50,6 +50,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -88,6 +89,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -133,6 +135,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/Integrations/Symfony/V6_2/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V6_2/TraceSearchConfigTest.php index a48c7aafbd..b032711526 100644 --- a/tests/Integrations/Symfony/V6_2/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V6_2/TraceSearchConfigTest.php @@ -42,6 +42,7 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', diff --git a/tests/Integrations/Symfony/V7_0/CommonScenariosTest.php b/tests/Integrations/Symfony/V7_0/CommonScenariosTest.php index 220c89f012..9c23b1970d 100644 --- a/tests/Integrations/Symfony/V7_0/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V7_0/CommonScenariosTest.php @@ -50,6 +50,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', + 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -88,6 +89,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', + 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -133,6 +135,7 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'App\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', + 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/composer.json b/tests/composer.json index f714b921d3..fe9224c225 100644 --- a/tests/composer.json +++ b/tests/composer.json @@ -17,6 +17,7 @@ "phpunit/phpunit": "<10", "phpspec/prophecy": "*", "symfony/process": "<5", + "symfony/routing": "<=6.0", "ext-sockets": "*" }, "config": { From a40badcba2026afdfda3dcdd456789b8224621d7 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Thu, 12 Dec 2024 08:05:03 -0300 Subject: [PATCH 2/7] symfony http.route: use existing hook instead --- Makefile | 3 - .../Symfony/SymfonyIntegration.php | 76 +++++++++---------- ...test.test_scenario_get_with_exception.json | 1 + ...rios_test.test_scenario_get_with_view.json | 1 + ...test.test_scenario_get_with_exception.json | 1 + ...rios_test.test_scenario_get_with_view.json | 1 + ...test.test_scenario_get_with_exception.json | 1 + ...rios_test.test_scenario_get_with_view.json | 1 + ..._test.test_scenario_get_return_string.json | 1 + ...test.test_scenario_get_with_exception.json | 1 + ...rios_test.test_scenario_get_with_view.json | 1 + ...ame_test.test_resource_to_uri_mapping.json | 1 + ..._test.test_scenario_get_return_string.json | 1 + ...test.test_scenario_get_with_exception.json | 1 + ...rios_test.test_scenario_get_with_view.json | 1 + ...ame_test.test_resource_to_uri_mapping.json | 1 + ...4_4.messenger_test.test_async_failure.json | 1 + ...4_4.messenger_test.test_async_success.json | 1 + ...async_with_tracer_disabled_on_consume.json | 1 + ...5_2.messenger_test.test_async_failure.json | 1 + ...5_2.messenger_test.test_async_success.json | 1 + ...async_with_tracer_disabled_on_consume.json | 1 + ...6_2.messenger_test.test_async_failure.json | 1 + ...6_2.messenger_test.test_async_success.json | 1 + ...async_with_tracer_disabled_on_consume.json | 1 + ...7_0.messenger_test.test_async_failure.json | 1 + ...7_0.messenger_test.test_async_success.json | 1 + ...async_with_tracer_disabled_on_consume.json | 1 + 28 files changed, 60 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index 87a4a56b70..205c0d5179 100644 --- a/Makefile +++ b/Makefile @@ -920,7 +920,6 @@ TEST_WEB_81 := \ test_web_nette_30 \ test_web_slim_312 \ test_web_slim_4 \ - test_web_symfony_52 \ test_web_wordpress_59 \ test_web_wordpress_61 \ test_web_custom \ @@ -981,7 +980,6 @@ TEST_WEB_82 := \ test_web_nette_30 \ test_web_slim_312 \ test_web_slim_4 \ - test_web_symfony_52 \ test_web_symfony_62 \ test_web_symfony_70 \ test_web_wordpress_59 \ @@ -1040,7 +1038,6 @@ TEST_WEB_83 := \ test_web_nette_30 \ test_web_slim_312 \ test_web_slim_4 \ - test_web_symfony_52 \ test_web_symfony_62 \ test_web_symfony_70 \ test_web_wordpress_59 \ diff --git a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php index 80668f9d9c..c28219d83e 100644 --- a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php +++ b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php @@ -10,9 +10,7 @@ use DDTrace\Type; use DDTrace\Util\Normalizer; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\ControllerEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\Routing\Route; class SymfonyIntegration extends Integration { @@ -24,6 +22,8 @@ class SymfonyIntegration extends Integration /** @var string */ public $frameworkPrefix = SymfonyIntegration::NAME; + public $kernel; + /** * {@inheritdoc} */ @@ -309,42 +309,6 @@ function ($This, $scope, $args) use ($integration) { } ); - \DDTrace\trace_method( - 'Symfony\Component\EventDispatcher\EventDispatcher', - 'dispatch', - function (SpanData $span, $args) { - $event = $args[0]; - - if (!($event instanceof ControllerEvent)) { - return; - } - - $request = $event->getRequest(); - $controller = $event->getController()[0]; - - if (!property_exists($controller, 'container')) { - return; - } - - $rc = new \ReflectionClass(get_class($controller)); - $container = $rc->getProperty('container'); - $container->setAccessible(true); - $container = $container->getValue($controller); - - $router = $container->get('router'); - $routeName = $request->attributes->get('_route'); - - $routeCollection = $router->getRouteCollection(); - /** @var Route $route */ - $route = $routeCollection->get($routeName); - if (!isset($route)) { - return; - } - $root_span = \DDTrace\root_span(); - $root_span->meta[Tag::HTTP_ROUTE] = $route->getPath(); - } - ); - $this->loadSymfony($this); return Integration::LOADED; @@ -393,6 +357,24 @@ function (SpanData $span) use ($class, $methodname) { ); */ + \DDTrace\hook_method( + 'Symfony\Component\HttpKernel\Kernel', + 'getHttpKernel', + null, + function ($object) use ($integration) { + $integration->kernel = $object; + } + ); + + \DDTrace\hook_method( + 'Drupal\Core\DrupalKernel', + 'getHttpKernel', + null, + function ($object) use ($integration) { + $integration->kernel = $object; + } + ); + \DDTrace\hook_method( 'Symfony\Component\HttpKernel\HttpKernel', '__construct', @@ -436,12 +418,22 @@ function_exists('datadog\appsec\push_address')) { \datadog\appsec\push_address("server.request.path_params", $parameters); } - $route = $request->get('_route'); - if (null !== $route && null !== $request) { + $route_name = $request->get('_route'); + if (null !== $route_name && null !== $request) { if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { - $rootSpan->resource = $route; + $rootSpan->resource = $route_name; + } + $rootSpan->meta['symfony.route.name'] = $route_name; + + if ($integration->kernel !== null) { + $container = $integration->kernel->getContainer(); + $router = $container->get('router'); + $routeCollection = $router->getRouteCollection(); + $route = $routeCollection->get($route_name); + if (isset($route)) { + $rootSpan->meta[Tag::HTTP_ROUTE] = $route->getPath(); + } } - $rootSpan->meta['symfony.route.name'] = $route; } } ); diff --git a/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_exception.json index ee7ee96a88..770091fee4 100644 --- a/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_exception.json @@ -15,6 +15,7 @@ "error.stack": "#0 [internal function]: Drupal\\datadog\\Controller\\DatadogController->error()\n#1 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()\n#2 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/Render/Renderer.php(592): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#3 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\\Core\\Render\\Renderer->executeInRenderContext()\n#4 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()\n#5 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()\n#7 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\\Component\\HttpKernel\\HttpKernel->handle()\n#8 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session->handle()\n#9 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()\n#10 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()\n#11 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle()\n#12 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\\Core\\StackMiddleware\\StackedHttpKernel->handle()\n#13 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/index.php(19): Drupal\\Core\\DrupalKernel->handle()\n#14 {main}", "error.type": "Exception", "http.method": "GET", + "http.route": "/error", "http.status_code": "500", "http.url": "http://localhost/error?key=value&", "runtime-id": "9909a648-1886-44d2-b341-b1ddc0f62f34", diff --git a/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_view.json index 16afc5508e..53ccf7e10f 100644 --- a/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_view.json @@ -11,6 +11,7 @@ "_dd.p.dm": "-0", "component": "drupal", "http.method": "GET", + "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/simple_view", "runtime-id": "cecb7d5b-eb5a-49f8-8374-29dce2d6fce6", diff --git a/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_exception.json index f30d57b633..0960487f0f 100644 --- a/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_exception.json @@ -15,6 +15,7 @@ "error.stack": "#0 [internal function]: Drupal\\datadog\\Controller\\DatadogController->error()\n#1 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()\n#2 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#3 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\\Core\\Render\\Renderer->executeInRenderContext()\n#4 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()\n#5 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()\n#7 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel->handle()\n#8 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle()\n#9 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()\n#10 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()\n#11 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle()\n#12 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\\StackedHttpKernel->handle()\n#13 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/index.php(19): Drupal\\Core\\DrupalKernel->handle()\n#14 {main}", "error.type": "Exception", "http.method": "GET", + "http.route": "/error", "http.status_code": "500", "http.url": "http://localhost/error?key=value&", "runtime-id": "692423cd-81b3-449e-a67e-43150df99f74", diff --git a/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_view.json index 42eaba32f3..50d551be74 100644 --- a/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_view.json @@ -11,6 +11,7 @@ "_dd.p.dm": "-0", "component": "drupal", "http.method": "GET", + "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/simple_view", "runtime-id": "692423cd-81b3-449e-a67e-43150df99f74", diff --git a/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_exception.json index d6a0f8f00d..15760a4b54 100644 --- a/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_exception.json @@ -15,6 +15,7 @@ "error.stack": "#0 [internal function]: Drupal\\datadog\\Controller\\DatadogController->error()\n#1 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()\n#2 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#3 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\\Core\\Render\\Renderer->executeInRenderContext()\n#4 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()\n#5 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()\n#7 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\\Component\\HttpKernel\\HttpKernel->handle()\n#8 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session->handle()\n#9 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()\n#10 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()\n#11 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle()\n#12 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\\StackedHttpKernel->handle()\n#13 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/index.php(19): Drupal\\Core\\DrupalKernel->handle()\n#14 {main}", "error.type": "Exception", "http.method": "GET", + "http.route": "/error", "http.status_code": "500", "http.url": "http://localhost/error?key=value&", "runtime-id": "3afe4427-fcda-4ade-bdc5-572a8c5f8b12", diff --git a/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_view.json index fbcc57a8a7..870ca01550 100644 --- a/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_view.json @@ -11,6 +11,7 @@ "_dd.p.dm": "-0", "component": "drupal", "http.method": "GET", + "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/simple_view", "runtime-id": "7a7b1e1f-04e8-41dc-82bd-81f24ef6e0a4", diff --git a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_return_string.json b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_return_string.json index 82348173bb..47f6496617 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_return_string.json +++ b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_return_string.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6661b34000000000", "component": "symfony", "http.method": "GET", + "http.route": "/simple", "http.status_code": "200", "http.url": "http://localhost/app.php/simple?key=value&", "runtime-id": "93535b2f-0ff1-4add-8907-53304703f545", diff --git a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_exception.json index e76f67bda8..aa81c0b610 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_exception.json @@ -17,6 +17,7 @@ "error.type": "Exception", "http.method": "GET", "http.status_code": "500", + "http.route": "/error", "http.url": "http://localhost/app.php/error?key=value&", "runtime-id": "93535b2f-0ff1-4add-8907-53304703f545", "span.kind": "server", diff --git a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_view.json index 02531a7ac6..3ac43968e0 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_view.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6661bc6500000000", "component": "symfony", "http.method": "GET", + "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/app.php/simple_view?key=value&", "runtime-id": "05d2d546-7cb6-4e46-bc10-0ff5602cdf9d", diff --git a/tests/snapshots/tests.integrations.symfony.v2_3.route_name_test.test_resource_to_uri_mapping.json b/tests/snapshots/tests.integrations.symfony.v2_3.route_name_test.test_resource_to_uri_mapping.json index 420610342c..f737bfa91e 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_3.route_name_test.test_resource_to_uri_mapping.json +++ b/tests/snapshots/tests.integrations.symfony.v2_3.route_name_test.test_resource_to_uri_mapping.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6661b35800000000", "component": "symfony", "http.method": "GET", + "http.route": "/", "http.status_code": "200", "http.url": "http://localhost/app.php?key=value&", "runtime-id": "7ddbbd63-c083-4257-a7f5-44101e551ef1", diff --git a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_return_string.json b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_return_string.json index a0a9c47464..706a7dcb5c 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_return_string.json +++ b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_return_string.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6660700300000000", "component": "symfony", "http.method": "GET", + "http.route": "/simple", "http.status_code": "200", "http.url": "http://localhost/app.php/simple?key=value&", "runtime-id": "4374c14f-def1-4b62-97c0-598f46322850", diff --git a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_exception.json index d5292f1bbf..c1798e3aba 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_exception.json @@ -16,6 +16,7 @@ "error.stack": "#0 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/app/bootstrap.php.cache(3275): AppBundle\\Controller\\CommonScenariosController->errorAction()\n#1 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/app/bootstrap.php.cache(3234): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()\n#2 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/app/bootstrap.php.cache(3388): Symfony\\Component\\HttpKernel\\HttpKernel->handle()\n#3 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/app/bootstrap.php.cache(2594): Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel->handle()\n#4 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/web/app.php(15): Symfony\\Component\\HttpKernel\\Kernel->handle()\n#5 {main}", "error.type": "Exception", "http.method": "GET", + "http.route": "/error", "http.status_code": "500", "http.url": "http://localhost/app.php/error?key=value&", "runtime-id": "4374c14f-def1-4b62-97c0-598f46322850", diff --git a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_view.json index 37bea1d81a..89d499bfa9 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_view.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6660709f00000000", "component": "symfony", "http.method": "GET", + "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/app.php/simple_view?key=value&", "runtime-id": "a908b910-f481-44e7-bf7b-8d48954a4639", diff --git a/tests/snapshots/tests.integrations.symfony.v2_8.route_name_test.test_resource_to_uri_mapping.json b/tests/snapshots/tests.integrations.symfony.v2_8.route_name_test.test_resource_to_uri_mapping.json index f6586cf06a..2e22ef9f84 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_8.route_name_test.test_resource_to_uri_mapping.json +++ b/tests/snapshots/tests.integrations.symfony.v2_8.route_name_test.test_resource_to_uri_mapping.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6660aaff00000000", "component": "symfony", "http.method": "GET", + "http.route": "/", "http.status_code": "200", "http.url": "http://localhost/app.php?key=value&", "runtime-id": "4b578cb2-1f1d-441e-aacb-a4aaff240713", diff --git a/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_failure.json b/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_failure.json index 4c9124c5ee..b744933452 100644 --- a/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_failure.json +++ b/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_failure.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6737718e00000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/fail", "http.status_code": "200", "http.url": "http://localhost/lucky/fail", "runtime-id": "d7b13848-ab88-43bb-853d-29cf4386f11e", diff --git a/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_success.json b/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_success.json index 6f9f55850a..7bccaa2e3c 100644 --- a/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_success.json +++ b/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_success.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6737717e00000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/number", "http.status_code": "200", "http.url": "http://localhost/lucky/number", "runtime-id": "d7b13848-ab88-43bb-853d-29cf4386f11e", diff --git a/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_with_tracer_disabled_on_consume.json b/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_with_tracer_disabled_on_consume.json index 826b01763f..b1f5cc64a0 100644 --- a/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_with_tracer_disabled_on_consume.json +++ b/tests/snapshots/tests.integrations.symfony.v4_4.messenger_test.test_async_with_tracer_disabled_on_consume.json @@ -12,6 +12,7 @@ "_dd.p.tid": "673771a400000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/number", "http.status_code": "200", "http.url": "http://localhost/lucky/number", "runtime-id": "d7b13848-ab88-43bb-853d-29cf4386f11e", diff --git a/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_failure.json b/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_failure.json index 01281ee5da..cd749e0d34 100644 --- a/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_failure.json +++ b/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_failure.json @@ -12,6 +12,7 @@ "_dd.p.tid": "67376f1600000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/fail", "http.status_code": "200", "http.url": "http://localhost/lucky/fail", "runtime-id": "88fa2001-f1cd-43a1-b3cc-fea77ce914b8", diff --git a/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_success.json b/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_success.json index 5b5d1fefc0..22d2d574dd 100644 --- a/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_success.json +++ b/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_success.json @@ -12,6 +12,7 @@ "_dd.p.tid": "67376ef700000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/number", "http.status_code": "200", "http.url": "http://localhost/lucky/number", "runtime-id": "88fa2001-f1cd-43a1-b3cc-fea77ce914b8", diff --git a/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_with_tracer_disabled_on_consume.json b/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_with_tracer_disabled_on_consume.json index 4b0fc7ddde..a1b118e509 100644 --- a/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_with_tracer_disabled_on_consume.json +++ b/tests/snapshots/tests.integrations.symfony.v5_2.messenger_test.test_async_with_tracer_disabled_on_consume.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6737620400000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/number", "http.status_code": "200", "http.url": "http://localhost/lucky/number", "runtime-id": "11678ecc-7ed1-443c-9c2a-7d803090723e", diff --git a/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_failure.json b/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_failure.json index bea7a584f0..4341464161 100644 --- a/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_failure.json +++ b/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_failure.json @@ -12,6 +12,7 @@ "_dd.p.tid": "67376acd00000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/fail", "http.status_code": "200", "http.url": "http://localhost/lucky/fail", "runtime-id": "ec06d36e-1a6e-48f5-a627-c724d35f765b", diff --git a/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_success.json b/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_success.json index 611c454674..5769a83c09 100644 --- a/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_success.json +++ b/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_success.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6737688900000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/number", "http.status_code": "200", "http.url": "http://localhost/lucky/number", "runtime-id": "5fe9f332-5cdf-4438-a2c1-35f9245e4015", diff --git a/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_with_tracer_disabled_on_consume.json b/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_with_tracer_disabled_on_consume.json index fc9a24837c..d9c5955b2e 100644 --- a/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_with_tracer_disabled_on_consume.json +++ b/tests/snapshots/tests.integrations.symfony.v6_2.messenger_test.test_async_with_tracer_disabled_on_consume.json @@ -12,6 +12,7 @@ "_dd.p.tid": "6737607d00000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/number", "http.status_code": "200", "http.url": "http://localhost/lucky/number", "runtime-id": "f05a51bb-8120-4e60-8705-ccc45d60b1c3", diff --git a/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_failure.json b/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_failure.json index 01fc32da5f..6f4f95e3d1 100644 --- a/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_failure.json +++ b/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_failure.json @@ -12,6 +12,7 @@ "_dd.p.tid": "67376d6700000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/fail", "http.status_code": "200", "http.url": "http://localhost/lucky/fail", "runtime-id": "34c72fce-60c5-4a66-b562-44064d3104ba", diff --git a/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_success.json b/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_success.json index 6871aa82b8..8656fbfb2f 100644 --- a/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_success.json +++ b/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_success.json @@ -12,6 +12,7 @@ "_dd.p.tid": "67376c0a00000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/number", "http.status_code": "200", "http.url": "http://localhost/lucky/number", "runtime-id": "1bbc4547-ce88-419f-b529-961bc1522710", diff --git a/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_with_tracer_disabled_on_consume.json b/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_with_tracer_disabled_on_consume.json index 0d636c332a..619efd5921 100644 --- a/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_with_tracer_disabled_on_consume.json +++ b/tests/snapshots/tests.integrations.symfony.v7_0.messenger_test.test_async_with_tracer_disabled_on_consume.json @@ -12,6 +12,7 @@ "_dd.p.tid": "673760aa00000000", "component": "symfony", "http.method": "GET", + "http.route": "/lucky/number", "http.status_code": "200", "http.url": "http://localhost/lucky/number", "runtime-id": "99fe2e1b-f085-435b-8e4a-909cfe1eeb25", From ca38a5477c36a251d5d70fbefd578deab75327b9 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Mon, 16 Dec 2024 10:14:43 -0300 Subject: [PATCH 3/7] Cache routes --- .../src/docker/php/build_dev_php.sh | 22 +++++--- .../Symfony/SymfonyIntegration.php | 55 ++++++++++++++----- .../Symfony/V3_0/CommonScenariosTest.php | 3 - ...test.test_scenario_get_with_exception.json | 1 - ...rios_test.test_scenario_get_with_view.json | 1 - ...test.test_scenario_get_with_exception.json | 1 - ...rios_test.test_scenario_get_with_view.json | 1 - ...test.test_scenario_get_with_exception.json | 1 - ...rios_test.test_scenario_get_with_view.json | 1 - ..._test.test_scenario_get_return_string.json | 1 - ...test.test_scenario_get_with_exception.json | 1 - ...rios_test.test_scenario_get_with_view.json | 1 - ...ame_test.test_resource_to_uri_mapping.json | 1 - ..._test.test_scenario_get_return_string.json | 1 - ...test.test_scenario_get_with_exception.json | 1 - ...rios_test.test_scenario_get_with_view.json | 1 - ...ame_test.test_resource_to_uri_mapping.json | 1 - 17 files changed, 53 insertions(+), 41 deletions(-) diff --git a/appsec/tests/integration/src/docker/php/build_dev_php.sh b/appsec/tests/integration/src/docker/php/build_dev_php.sh index ed6e1ed9c0..55742f0dc7 100755 --- a/appsec/tests/integration/src/docker/php/build_dev_php.sh +++ b/appsec/tests/integration/src/docker/php/build_dev_php.sh @@ -86,10 +86,12 @@ function run_dsymutil { fi local readonly dir=$1 exe= find "$dir" -type f -exec test -x '{}' \; -print | while read -r exe; do - if ! grep -q '^#!' "$exe"; then - local readonly dSYM_DIR="${exe}.dSYM" - if [[ ! -d $dSYM_DIR ]]; then - dsymutil "$exe" + if [[ $exe != *.a ]]; then + if ! grep -q '^#!' "$exe"; then + local readonly dSYM_DIR="${exe}.dSYM" + if [[ ! -d $dSYM_DIR ]]; then + dsymutil "$exe" + fi fi fi done @@ -98,14 +100,16 @@ function run_dsymutil { function get_xdebug_version { local -r version=$1 local readonly version_id=$(php_version_id $version) - if [[ $version_id -lt 70300 ]]; then - echo '2.8.1' - elif [[ $version_id -lt 80000 ]]; then + if [[ $version_id -lt 70100 ]]; then + echo '2.6.1' + elif [[ $version_id -lt 70200 ]]; then echo '2.9.8' + elif [[ $version_id -lt 80000 ]]; then + echo '3.1.6' elif [[ $version_id -lt 80400 ]]; then - echo '3.3.1' + echo '3.3.2' elif [[ $version_id -ge 80400 ]]; then - echo '3.4.0beta1' + echo '3.4.0' fi } diff --git a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php index c28219d83e..6e9decabc9 100644 --- a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php +++ b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php @@ -9,8 +9,10 @@ use DDTrace\Tag; use DDTrace\Type; use DDTrace\Util\Normalizer; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Contracts\Cache\ItemInterface; class SymfonyIntegration extends Integration { @@ -419,21 +421,44 @@ function_exists('datadog\appsec\push_address')) { } $route_name = $request->get('_route'); - if (null !== $route_name && null !== $request) { - if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { - $rootSpan->resource = $route_name; - } - $rootSpan->meta['symfony.route.name'] = $route_name; - - if ($integration->kernel !== null) { - $container = $integration->kernel->getContainer(); - $router = $container->get('router'); - $routeCollection = $router->getRouteCollection(); - $route = $routeCollection->get($route_name); - if (isset($route)) { - $rootSpan->meta[Tag::HTTP_ROUTE] = $route->getPath(); - } - } + if ($route_name === null) { + return; + } + if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { + $rootSpan->resource = $route_name; + } + $rootSpan->meta['symfony.route.name'] = $route_name; + + // the rest is for determining http.route + if ($integration->kernel === null) { + return; + } + /** @var ContainerInterface $container */ + $container = $integration->kernel->getContainer(); + $cache = null; + try { + $cache = $container->get('cache.app'); + } catch (\Exception $e) { + return; + } + + /** @var \Symfony\Bundle\FrameworkBundle\Routing\Router $router */ + $router = $container->get('router'); + if (!\method_exists($cache, 'getItem')) { + return; + } + $item = $cache->getItem("_datadog.route.path.$route_name"); + if ($item->isHit()) { + $route = $item->get(); + } else { + $routeCollection = $router->getRouteCollection(); + $route = $routeCollection->get($route_name); + $item->set($route); + $item->expiresAfter(3600); + $cache->save($item); + } + if (isset($route)) { + $rootSpan->meta[Tag::HTTP_ROUTE] = $route->getPath(); } } ); diff --git a/tests/Integrations/Symfony/V3_0/CommonScenariosTest.php b/tests/Integrations/Symfony/V3_0/CommonScenariosTest.php index 3e99d03780..4f9d14068d 100644 --- a/tests/Integrations/Symfony/V3_0/CommonScenariosTest.php +++ b/tests/Integrations/Symfony/V3_0/CommonScenariosTest.php @@ -42,7 +42,6 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', - 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple?key=value&', 'http.status_code' => '200', @@ -80,7 +79,6 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleViewAction', 'symfony.route.name' => 'simple_view', - 'http.route' => '/simple_view', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple_view?key=value&', 'http.status_code' => '200', @@ -127,7 +125,6 @@ public function provideSpecs() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@errorAction', 'symfony.route.name' => 'error', - 'http.route' => '/error', 'http.method' => 'GET', 'http.url' => 'http://localhost/error?key=value&', 'http.status_code' => '500', diff --git a/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_exception.json index 770091fee4..ee7ee96a88 100644 --- a/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_exception.json @@ -15,7 +15,6 @@ "error.stack": "#0 [internal function]: Drupal\\datadog\\Controller\\DatadogController->error()\n#1 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()\n#2 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/Render/Renderer.php(592): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#3 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\\Core\\Render\\Renderer->executeInRenderContext()\n#4 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()\n#5 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()\n#7 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\\Component\\HttpKernel\\HttpKernel->handle()\n#8 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session->handle()\n#9 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()\n#10 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()\n#11 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle()\n#12 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\\Core\\StackMiddleware\\StackedHttpKernel->handle()\n#13 /home/circleci/app/tests/Frameworks/Drupal/Version_10_1/index.php(19): Drupal\\Core\\DrupalKernel->handle()\n#14 {main}", "error.type": "Exception", "http.method": "GET", - "http.route": "/error", "http.status_code": "500", "http.url": "http://localhost/error?key=value&", "runtime-id": "9909a648-1886-44d2-b341-b1ddc0f62f34", diff --git a/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_view.json index 53ccf7e10f..16afc5508e 100644 --- a/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.drupal.v10_1.common_scenarios_test.test_scenario_get_with_view.json @@ -11,7 +11,6 @@ "_dd.p.dm": "-0", "component": "drupal", "http.method": "GET", - "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/simple_view", "runtime-id": "cecb7d5b-eb5a-49f8-8374-29dce2d6fce6", diff --git a/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_exception.json index 0960487f0f..f30d57b633 100644 --- a/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_exception.json @@ -15,7 +15,6 @@ "error.stack": "#0 [internal function]: Drupal\\datadog\\Controller\\DatadogController->error()\n#1 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()\n#2 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#3 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\\Core\\Render\\Renderer->executeInRenderContext()\n#4 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()\n#5 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()\n#7 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel->handle()\n#8 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle()\n#9 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()\n#10 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()\n#11 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle()\n#12 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\\StackedHttpKernel->handle()\n#13 /home/circleci/app/tests/Frameworks/Drupal/Version_8_9/index.php(19): Drupal\\Core\\DrupalKernel->handle()\n#14 {main}", "error.type": "Exception", "http.method": "GET", - "http.route": "/error", "http.status_code": "500", "http.url": "http://localhost/error?key=value&", "runtime-id": "692423cd-81b3-449e-a67e-43150df99f74", diff --git a/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_view.json index 50d551be74..42eaba32f3 100644 --- a/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.drupal.v8_9.common_scenarios_test.test_scenario_get_with_view.json @@ -11,7 +11,6 @@ "_dd.p.dm": "-0", "component": "drupal", "http.method": "GET", - "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/simple_view", "runtime-id": "692423cd-81b3-449e-a67e-43150df99f74", diff --git a/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_exception.json index 15760a4b54..d6a0f8f00d 100644 --- a/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_exception.json @@ -15,7 +15,6 @@ "error.stack": "#0 [internal function]: Drupal\\datadog\\Controller\\DatadogController->error()\n#1 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()\n#2 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#3 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\\Core\\Render\\Renderer->executeInRenderContext()\n#4 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()\n#5 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()\n#7 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\\Component\\HttpKernel\\HttpKernel->handle()\n#8 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session->handle()\n#9 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()\n#10 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()\n#11 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle()\n#12 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\\StackedHttpKernel->handle()\n#13 /home/circleci/app/tests/Frameworks/Drupal/Version_9_5/index.php(19): Drupal\\Core\\DrupalKernel->handle()\n#14 {main}", "error.type": "Exception", "http.method": "GET", - "http.route": "/error", "http.status_code": "500", "http.url": "http://localhost/error?key=value&", "runtime-id": "3afe4427-fcda-4ade-bdc5-572a8c5f8b12", diff --git a/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_view.json index 870ca01550..fbcc57a8a7 100644 --- a/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.drupal.v9_5.common_scenarios_test.test_scenario_get_with_view.json @@ -11,7 +11,6 @@ "_dd.p.dm": "-0", "component": "drupal", "http.method": "GET", - "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/simple_view", "runtime-id": "7a7b1e1f-04e8-41dc-82bd-81f24ef6e0a4", diff --git a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_return_string.json b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_return_string.json index 47f6496617..82348173bb 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_return_string.json +++ b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_return_string.json @@ -12,7 +12,6 @@ "_dd.p.tid": "6661b34000000000", "component": "symfony", "http.method": "GET", - "http.route": "/simple", "http.status_code": "200", "http.url": "http://localhost/app.php/simple?key=value&", "runtime-id": "93535b2f-0ff1-4add-8907-53304703f545", diff --git a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_exception.json index aa81c0b610..e76f67bda8 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_exception.json @@ -17,7 +17,6 @@ "error.type": "Exception", "http.method": "GET", "http.status_code": "500", - "http.route": "/error", "http.url": "http://localhost/app.php/error?key=value&", "runtime-id": "93535b2f-0ff1-4add-8907-53304703f545", "span.kind": "server", diff --git a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_view.json index 3ac43968e0..02531a7ac6 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.symfony.v2_3.common_scenarios_test.test_scenario_get_with_view.json @@ -12,7 +12,6 @@ "_dd.p.tid": "6661bc6500000000", "component": "symfony", "http.method": "GET", - "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/app.php/simple_view?key=value&", "runtime-id": "05d2d546-7cb6-4e46-bc10-0ff5602cdf9d", diff --git a/tests/snapshots/tests.integrations.symfony.v2_3.route_name_test.test_resource_to_uri_mapping.json b/tests/snapshots/tests.integrations.symfony.v2_3.route_name_test.test_resource_to_uri_mapping.json index f737bfa91e..420610342c 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_3.route_name_test.test_resource_to_uri_mapping.json +++ b/tests/snapshots/tests.integrations.symfony.v2_3.route_name_test.test_resource_to_uri_mapping.json @@ -12,7 +12,6 @@ "_dd.p.tid": "6661b35800000000", "component": "symfony", "http.method": "GET", - "http.route": "/", "http.status_code": "200", "http.url": "http://localhost/app.php?key=value&", "runtime-id": "7ddbbd63-c083-4257-a7f5-44101e551ef1", diff --git a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_return_string.json b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_return_string.json index 706a7dcb5c..a0a9c47464 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_return_string.json +++ b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_return_string.json @@ -12,7 +12,6 @@ "_dd.p.tid": "6660700300000000", "component": "symfony", "http.method": "GET", - "http.route": "/simple", "http.status_code": "200", "http.url": "http://localhost/app.php/simple?key=value&", "runtime-id": "4374c14f-def1-4b62-97c0-598f46322850", diff --git a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_exception.json b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_exception.json index c1798e3aba..d5292f1bbf 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_exception.json +++ b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_exception.json @@ -16,7 +16,6 @@ "error.stack": "#0 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/app/bootstrap.php.cache(3275): AppBundle\\Controller\\CommonScenariosController->errorAction()\n#1 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/app/bootstrap.php.cache(3234): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()\n#2 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/app/bootstrap.php.cache(3388): Symfony\\Component\\HttpKernel\\HttpKernel->handle()\n#3 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/app/bootstrap.php.cache(2594): Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel->handle()\n#4 /home/circleci/app/tests/Frameworks/Symfony/Version_2_8/web/app.php(15): Symfony\\Component\\HttpKernel\\Kernel->handle()\n#5 {main}", "error.type": "Exception", "http.method": "GET", - "http.route": "/error", "http.status_code": "500", "http.url": "http://localhost/app.php/error?key=value&", "runtime-id": "4374c14f-def1-4b62-97c0-598f46322850", diff --git a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_view.json b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_view.json index 89d499bfa9..37bea1d81a 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_view.json +++ b/tests/snapshots/tests.integrations.symfony.v2_8.common_scenarios_test.test_scenario_get_with_view.json @@ -12,7 +12,6 @@ "_dd.p.tid": "6660709f00000000", "component": "symfony", "http.method": "GET", - "http.route": "/simple_view", "http.status_code": "200", "http.url": "http://localhost/app.php/simple_view?key=value&", "runtime-id": "a908b910-f481-44e7-bf7b-8d48954a4639", diff --git a/tests/snapshots/tests.integrations.symfony.v2_8.route_name_test.test_resource_to_uri_mapping.json b/tests/snapshots/tests.integrations.symfony.v2_8.route_name_test.test_resource_to_uri_mapping.json index 2e22ef9f84..f6586cf06a 100644 --- a/tests/snapshots/tests.integrations.symfony.v2_8.route_name_test.test_resource_to_uri_mapping.json +++ b/tests/snapshots/tests.integrations.symfony.v2_8.route_name_test.test_resource_to_uri_mapping.json @@ -12,7 +12,6 @@ "_dd.p.tid": "6660aaff00000000", "component": "symfony", "http.method": "GET", - "http.route": "/", "http.status_code": "200", "http.url": "http://localhost/app.php?key=value&", "runtime-id": "4b578cb2-1f1d-441e-aacb-a4aaff240713", From 9fbe7c674ce1a245b1a269f8821784ad6494e843 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Wed, 18 Dec 2024 12:14:17 -0300 Subject: [PATCH 4/7] Support localized routes --- .../Symfony/SymfonyIntegration.php | 97 +++++++++++-------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php index 6e9decabc9..02e1e03457 100644 --- a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php +++ b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php @@ -388,10 +388,62 @@ function () use ($integration) { } ); + $handle_route = function($request, $rootSpan) use ($integration) { + $route_name = $request->get('_route'); + if ($route_name === null) { + return; + } + if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { + $rootSpan->resource = $route_name; + } + $rootSpan->meta['symfony.route.name'] = $route_name; + + // the rest is for determining http.route + if ($integration->kernel === null) { + return; + } + /** @var ContainerInterface $container */ + $container = $integration->kernel->getContainer(); + $cache = null; + try { + $cache = $container->get('cache.app'); + } catch (\Exception $e) { + return; + } + + /** @var \Symfony\Bundle\FrameworkBundle\Routing\Router $router */ + $router = $container->get('router'); + if (!\method_exists($cache, 'getItem')) { + return; + } + $itemName = "_datadog.route.path.$route_name"; + $locale = $request->get('_locale'); + if ($locale !== null) { + $itemName .= ".$locale"; + } + $item = $cache->getItem($itemName); + if ($item->isHit()) { + $route = $item->get(); + } else { + $routeCollection = $router->getRouteCollection(); + $route = $routeCollection->get($route_name); + if ($route == null && ($locale = $request->get('_locale')) !== null) { + $route = $routeCollection->get($route_name . '.' . $locale); + } + $item->set($route); + $item->expiresAfter(3600); + $cache->save($item); + } + if (isset($route)) { + $rootSpan->meta[Tag::HTTP_ROUTE] = $route->getPath(); + } + + }; + \DDTrace\trace_method( 'Symfony\Component\HttpKernel\HttpKernel', 'handle', - function (SpanData $span, $args, $response) use ($integration) { + function (SpanData $span, $args, $response) use ($integration, $handle_route) { /** @var Request $request */ list($request) = $args; @@ -413,53 +465,14 @@ function (SpanData $span, $args, $response) use ($integration) { $rootSpan->meta[Tag::HTTP_STATUS_CODE] = $response->getStatusCode(); } + $handle_route($request, $rootSpan); + $parameters = $request->get('_route_params'); if (!empty($parameters) && is_array($parameters) && function_exists('datadog\appsec\push_address')) { \datadog\appsec\push_address("server.request.path_params", $parameters); } - - $route_name = $request->get('_route'); - if ($route_name === null) { - return; - } - if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { - $rootSpan->resource = $route_name; - } - $rootSpan->meta['symfony.route.name'] = $route_name; - - // the rest is for determining http.route - if ($integration->kernel === null) { - return; - } - /** @var ContainerInterface $container */ - $container = $integration->kernel->getContainer(); - $cache = null; - try { - $cache = $container->get('cache.app'); - } catch (\Exception $e) { - return; - } - - /** @var \Symfony\Bundle\FrameworkBundle\Routing\Router $router */ - $router = $container->get('router'); - if (!\method_exists($cache, 'getItem')) { - return; - } - $item = $cache->getItem("_datadog.route.path.$route_name"); - if ($item->isHit()) { - $route = $item->get(); - } else { - $routeCollection = $router->getRouteCollection(); - $route = $routeCollection->get($route_name); - $item->set($route); - $item->expiresAfter(3600); - $cache->save($item); - } - if (isset($route)) { - $rootSpan->meta[Tag::HTTP_ROUTE] = $route->getPath(); - } } ); From 537f1f118aea12eb4e228f2cfff27e0ef308d255 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Wed, 18 Dec 2024 12:31:03 -0300 Subject: [PATCH 5/7] Fix symfony 3.0 test --- .../com/datadog/appsec/php/integration/Symfony62Tests.groovy | 1 + .../src/test/www/symfony62/src/Controller/HomeController.php | 3 ++- tests/Integrations/Symfony/V3_0/TraceSearchConfigTest.php | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/Symfony62Tests.groovy b/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/Symfony62Tests.groovy index 5ae5e1be81..5af8b25a9e 100644 --- a/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/Symfony62Tests.groovy +++ b/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/Symfony62Tests.groovy @@ -113,5 +113,6 @@ class Symfony62Tests { assert span.metrics."_dd.appsec.waf.duration" > 0.0d assert span.meta."_dd.appsec.event_rules.version" != '' assert span.meta."appsec.blocked" == "true" + assert span.meta."http.route" == '/dynamic-path/{param01}' } } diff --git a/appsec/tests/integration/src/test/www/symfony62/src/Controller/HomeController.php b/appsec/tests/integration/src/test/www/symfony62/src/Controller/HomeController.php index 7fbe2fc90e..006e9a8882 100644 --- a/appsec/tests/integration/src/test/www/symfony62/src/Controller/HomeController.php +++ b/appsec/tests/integration/src/test/www/symfony62/src/Controller/HomeController.php @@ -21,7 +21,8 @@ public function homeAction(Request $request) ); } - #[Route("/dynamic-path/{param01}")] + #[Route("/dynamic-path/{param01}", locale: "en")] + #[Route("/caminho-dinamico/{param01}", locale: "pt")] public function dynamicAction(Request $request, string $param01) { return new Response( diff --git a/tests/Integrations/Symfony/V3_0/TraceSearchConfigTest.php b/tests/Integrations/Symfony/V3_0/TraceSearchConfigTest.php index bf934a5c46..82be10bfa6 100644 --- a/tests/Integrations/Symfony/V3_0/TraceSearchConfigTest.php +++ b/tests/Integrations/Symfony/V3_0/TraceSearchConfigTest.php @@ -42,7 +42,6 @@ public function testScenario() )->withExactTags([ 'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleAction', 'symfony.route.name' => 'simple', - 'http.route' => '/simple', 'http.method' => 'GET', 'http.url' => 'http://localhost/simple', 'http.status_code' => '200', From 7010b37d5a2aa1adaa00ed51ba02edc2b5e82733 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Fri, 20 Dec 2024 13:03:33 -0300 Subject: [PATCH 6/7] Small refactoring --- .../Symfony/SymfonyIntegration.php | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php index 02e1e03457..63cf605206 100644 --- a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php +++ b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php @@ -388,23 +388,12 @@ function () use ($integration) { } ); - $handle_route = function($request, $rootSpan) use ($integration) { - $route_name = $request->get('_route'); - if ($route_name === null) { - return; - } - if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { - $rootSpan->resource = $route_name; - } - $rootSpan->meta['symfony.route.name'] = $route_name; - - // the rest is for determining http.route + $handle_http_route = function($route_name, $request, $rootSpan) use ($integration) { if ($integration->kernel === null) { return; } /** @var ContainerInterface $container */ $container = $integration->kernel->getContainer(); - $cache = null; try { $cache = $container->get('cache.app'); } catch (\Exception $e) { @@ -437,13 +426,12 @@ function () use ($integration) { if (isset($route)) { $rootSpan->meta[Tag::HTTP_ROUTE] = $route->getPath(); } - }; \DDTrace\trace_method( 'Symfony\Component\HttpKernel\HttpKernel', 'handle', - function (SpanData $span, $args, $response) use ($integration, $handle_route) { + function (SpanData $span, $args, $response) use ($integration, $handle_http_route) { /** @var Request $request */ list($request) = $args; @@ -465,7 +453,14 @@ function (SpanData $span, $args, $response) use ($integration, $handle_route) { $rootSpan->meta[Tag::HTTP_STATUS_CODE] = $response->getStatusCode(); } - $handle_route($request, $rootSpan); + $route_name = $request->get('_route'); + if ($route_name !== null) { + if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { + $rootSpan->resource = $route_name; + } + $rootSpan->meta['symfony.route.name'] = $route_name; + $handle_http_route($route_name, $request, $rootSpan); + } $parameters = $request->get('_route_params'); if (!empty($parameters) && From 04884ce5f57a0dc250d07e1d3601682df96ae33b Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Wed, 15 Jan 2025 16:31:43 -0300 Subject: [PATCH 7/7] Add option to disable http.route in symfony --- appsec/tests/integration/build.gradle | 1 + appsec/tests/integration/gradle/images.gradle | 1 + .../src/docker/php/build_dev_php.sh | 2 +- .../php/integration/Symfony62Tests.groovy | 33 +++- ext/configuration.h | 1 + .../Symfony/SymfonyIntegration.php | 148 +++++++++--------- 6 files changed, 105 insertions(+), 81 deletions(-) diff --git a/appsec/tests/integration/build.gradle b/appsec/tests/integration/build.gradle index 7b0d3406a3..bb4060747c 100644 --- a/appsec/tests/integration/build.gradle +++ b/appsec/tests/integration/build.gradle @@ -438,6 +438,7 @@ task loadCaches(type: Exec) { commandLine 'docker', 'run', '--rm', '-v', 'php-tracer-cargo-cache:/caches/php-tracer-cargo-cache', + '-v', 'php-tracer-cargo-cache-git:/caches/php-tracer-cargo-cache-git', '-v', 'php-appsec-hunter-cache:/caches/php-appsec-hunter-cache', '-v', "${project.buildDir}:/build", 'busybox', diff --git a/appsec/tests/integration/gradle/images.gradle b/appsec/tests/integration/gradle/images.gradle index 4b6e82041b..d6823c473c 100644 --- a/appsec/tests/integration/gradle/images.gradle +++ b/appsec/tests/integration/gradle/images.gradle @@ -234,6 +234,7 @@ task saveCaches(type: Exec) { commandLine 'docker', 'run', '--rm', '-e', "UUID=${uuid}", '-v', 'php-tracer-cargo-cache:/caches/php-tracer-cargo-cache', + '-v', 'php-tracer-cargo-cache-git:/caches/php-tracer-cargo-cache-git', '-v', 'php-appsec-hunter-cache:/caches/php-appsec-hunter-cache', '-v', "${project.buildDir}:/build", 'busybox', diff --git a/appsec/tests/integration/src/docker/php/build_dev_php.sh b/appsec/tests/integration/src/docker/php/build_dev_php.sh index 55742f0dc7..c7688f2af2 100755 --- a/appsec/tests/integration/src/docker/php/build_dev_php.sh +++ b/appsec/tests/integration/src/docker/php/build_dev_php.sh @@ -504,7 +504,7 @@ fi if [[ -d /opt/homebrew/lib ]]; then export LDFLAGS="${LDFLAGS:-} -L/opt/homebrew/lib" - export CPPFLAGS="${CPPFLAGS:-} -I/opt/homebrew/include" + export CPPFLAGS="${CPPFLAGS:-} -idirafter /opt/homebrew/include" fi export CXXFLAGS="${CXXFLAGS:-} -std=c++11" export CFLAGS="${CFLAGS:-} -Wno-implicit-function-declaration" diff --git a/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/Symfony62Tests.groovy b/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/Symfony62Tests.groovy index 5af8b25a9e..98b6cae496 100644 --- a/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/Symfony62Tests.groovy +++ b/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/Symfony62Tests.groovy @@ -6,7 +6,6 @@ import com.datadog.appsec.php.docker.InspectContainerHelper import com.datadog.appsec.php.model.Span import com.datadog.appsec.php.model.Trace import org.junit.jupiter.api.MethodOrderer -import org.junit.jupiter.api.Order import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestMethodOrder import org.junit.jupiter.api.condition.EnabledIf @@ -45,12 +44,6 @@ class Symfony62Tests { www: 'symfony62', ) - @Test - @Order(1) - void 'reported telemetry integrations are not repeated'() { - - } - @Test void 'login success automated event'() { //The user ciuser@example.com is already on the DB @@ -115,4 +108,30 @@ class Symfony62Tests { assert span.meta."appsec.blocked" == "true" assert span.meta."http.route" == '/dynamic-path/{param01}' } + + @Test + void 'symfony http route disabled'() { + try { + def res = CONTAINER.execInContainer( + 'bash', '-c', + '''echo export DD_TRACE_SYMFONY_HTTP_ROUTE=false >> /etc/apache2/envvars; + service apache2 restart''') + assert res.exitCode == 0 + + HttpRequest req = container.buildReq('/dynamic-path/someValue').GET().build() + def trace = container.traceFromRequest(req, ofString()) { HttpResponse re -> + assert re.statusCode() == 200 + assert re.body().contains('Hi someValue!') + } + + Span span = trace.first() + assert span.meta."http.route" != '/dynamic-path/{param01}' + } finally { + def res = CONTAINER.execInContainer( + 'bash', '-c', + '''sed -i '/export DD_TRACE_SYMFONY_HTTP_ROUTE=/d' /etc/apache2/envvars; + service apache2 restart''') + assert res.exitCode == 0 + } + } } diff --git a/ext/configuration.h b/ext/configuration.h index 970b97f212..5520a1e3fd 100644 --- a/ext/configuration.h +++ b/ext/configuration.h @@ -141,6 +141,7 @@ enum ddtrace_sampling_rules_format { CONFIG(BOOL, DD_TRACE_LARAVEL_QUEUE_DISTRIBUTED_TRACING, "true") \ CONFIG(BOOL, DD_TRACE_SYMFONY_MESSENGER_DISTRIBUTED_TRACING, "true") \ CONFIG(BOOL, DD_TRACE_SYMFONY_MESSENGER_MIDDLEWARES, "false") \ + CONFIG(BOOL, DD_TRACE_SYMFONY_HTTP_ROUTE, "true") \ CONFIG(BOOL, DD_TRACE_REMOVE_ROOT_SPAN_LARAVEL_QUEUE, "true") \ CONFIG(BOOL, DD_TRACE_REMOVE_ROOT_SPAN_SYMFONY_MESSENGER, "true") \ CONFIG(BOOL, DD_APPSEC_RASP_ENABLED , "false") \ diff --git a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php index 63cf605206..40fff04fcd 100644 --- a/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php +++ b/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php @@ -388,88 +388,90 @@ function () use ($integration) { } ); - $handle_http_route = function($route_name, $request, $rootSpan) use ($integration) { - if ($integration->kernel === null) { - return; - } - /** @var ContainerInterface $container */ - $container = $integration->kernel->getContainer(); - try { - $cache = $container->get('cache.app'); - } catch (\Exception $e) { - return; - } + if (\dd_trace_env_config('DD_TRACE_SYMFONY_HTTP_ROUTE')) { + $handle_http_route = function($route_name, $request, $rootSpan) use ($integration) { + if ($integration->kernel === null) { + return; + } + /** @var ContainerInterface $container */ + $container = $integration->kernel->getContainer(); + try { + $cache = $container->get('cache.app'); + } catch (\Exception $e) { + return; + } - /** @var \Symfony\Bundle\FrameworkBundle\Routing\Router $router */ - $router = $container->get('router'); - if (!\method_exists($cache, 'getItem')) { - return; - } - $itemName = "_datadog.route.path.$route_name"; - $locale = $request->get('_locale'); - if ($locale !== null) { - $itemName .= ".$locale"; - } - $item = $cache->getItem($itemName); - if ($item->isHit()) { - $route = $item->get(); - } else { - $routeCollection = $router->getRouteCollection(); - $route = $routeCollection->get($route_name); - if ($route == null && ($locale = $request->get('_locale')) !== null) { - $route = $routeCollection->get($route_name . '.' . $locale); - } - $item->set($route); - $item->expiresAfter(3600); - $cache->save($item); - } - if (isset($route)) { - $rootSpan->meta[Tag::HTTP_ROUTE] = $route->getPath(); - } - }; + /** @var \Symfony\Bundle\FrameworkBundle\Routing\Router $router */ + $router = $container->get('router'); + if (!\method_exists($cache, 'getItem')) { + return; + } + $itemName = "_datadog.route.path.$route_name"; + $locale = $request->get('_locale'); + if ($locale !== null) { + $itemName .= ".$locale"; + } + $item = $cache->getItem($itemName); + if ($item->isHit()) { + $route = $item->get(); + } else { + $routeCollection = $router->getRouteCollection(); + $route = $routeCollection->get($route_name); + if ($route == null && ($locale = $request->get('_locale')) !== null) { + $route = $routeCollection->get($route_name . '.' . $locale); + } + $item->set($route); + $item->expiresAfter(3600); + $cache->save($item); + } + if (isset($route)) { + $rootSpan->meta[Tag::HTTP_ROUTE] = $route->getPath(); + } + }; - \DDTrace\trace_method( - 'Symfony\Component\HttpKernel\HttpKernel', - 'handle', - function (SpanData $span, $args, $response) use ($integration, $handle_http_route) { - /** @var Request $request */ - list($request) = $args; + \DDTrace\trace_method( + 'Symfony\Component\HttpKernel\HttpKernel', + 'handle', + function (SpanData $span, $args, $response) use ($integration, $handle_http_route) { + /** @var Request $request */ + list($request) = $args; - $span->name = 'symfony.kernel.handle'; - $span->service = \ddtrace_config_app_name($integration->frameworkPrefix); - $span->type = Type::WEB_SERVLET; - $span->meta[Tag::COMPONENT] = SymfonyIntegration::NAME; + $span->name = 'symfony.kernel.handle'; + $span->service = \ddtrace_config_app_name($integration->frameworkPrefix); + $span->type = Type::WEB_SERVLET; + $span->meta[Tag::COMPONENT] = SymfonyIntegration::NAME; - $rootSpan = \DDTrace\root_span(); - $rootSpan->meta[Tag::HTTP_METHOD] = $request->getMethod(); - $rootSpan->meta[Tag::COMPONENT] = $integration->frameworkPrefix; - $rootSpan->meta[Tag::SPAN_KIND] = 'server'; - $integration->addTraceAnalyticsIfEnabled($rootSpan); + $rootSpan = \DDTrace\root_span(); + $rootSpan->meta[Tag::HTTP_METHOD] = $request->getMethod(); + $rootSpan->meta[Tag::COMPONENT] = $integration->frameworkPrefix; + $rootSpan->meta[Tag::SPAN_KIND] = 'server'; + $integration->addTraceAnalyticsIfEnabled($rootSpan); - if (!array_key_exists(Tag::HTTP_URL, $rootSpan->meta)) { - $rootSpan->meta[Tag::HTTP_URL] = Normalizer::urlSanitize($request->getUri()); - } - if (isset($response)) { - $rootSpan->meta[Tag::HTTP_STATUS_CODE] = $response->getStatusCode(); - } + if (!array_key_exists(Tag::HTTP_URL, $rootSpan->meta)) { + $rootSpan->meta[Tag::HTTP_URL] = Normalizer::urlSanitize($request->getUri()); + } + if (isset($response)) { + $rootSpan->meta[Tag::HTTP_STATUS_CODE] = $response->getStatusCode(); + } - $route_name = $request->get('_route'); - if ($route_name !== null) { - if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { - $rootSpan->resource = $route_name; + $route_name = $request->get('_route'); + if ($route_name !== null) { + if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { + $rootSpan->resource = $route_name; + } + $rootSpan->meta['symfony.route.name'] = $route_name; + $handle_http_route($route_name, $request, $rootSpan); } - $rootSpan->meta['symfony.route.name'] = $route_name; - $handle_http_route($route_name, $request, $rootSpan); - } - $parameters = $request->get('_route_params'); - if (!empty($parameters) && - is_array($parameters) && - function_exists('datadog\appsec\push_address')) { - \datadog\appsec\push_address("server.request.path_params", $parameters); + $parameters = $request->get('_route_params'); + if (!empty($parameters) && + is_array($parameters) && + function_exists('datadog\appsec\push_address')) { + \datadog\appsec\push_address("server.request.path_params", $parameters); + } } - } - ); + ); + } /* * EventDispatcher v4.3 introduced an arg hack that mutates the arguments.