diff --git a/src/Integrations/Integrations/Yii/YiiIntegration.php b/src/Integrations/Integrations/Yii/YiiIntegration.php index db5f8211db..1de4409585 100644 --- a/src/Integrations/Integrations/Yii/YiiIntegration.php +++ b/src/Integrations/Integrations/Yii/YiiIntegration.php @@ -165,6 +165,7 @@ function (SpanData $span, $args) use (&$firstController, $service) { ); $rootSpan->meta['app.route.path'] = $routePath; + $rootSpan->meta[Tag::HTTP_ROUTE] = $routePath; if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) { $resourceName = \str_replace( diff --git a/tests/Frameworks/Yii/Version_2_0/config/web.php b/tests/Frameworks/Yii/Version_2_0/config/web.php index ce6aa3aaf6..0053c93c2a 100644 --- a/tests/Frameworks/Yii/Version_2_0/config/web.php +++ b/tests/Frameworks/Yii/Version_2_0/config/web.php @@ -59,6 +59,7 @@ 'simple' => 'simple/index', 'simple_view' => 'simple/view', 'error' => 'simple/error', + 'parameterized/' => 'simple/parameterized', 'homes///' => 'homes/view', 'forum///' => 'forum/module/view', ], diff --git a/tests/Frameworks/Yii/Version_2_0/controllers/SimpleController.php b/tests/Frameworks/Yii/Version_2_0/controllers/SimpleController.php index 73174e44c5..36729235b0 100644 --- a/tests/Frameworks/Yii/Version_2_0/controllers/SimpleController.php +++ b/tests/Frameworks/Yii/Version_2_0/controllers/SimpleController.php @@ -30,4 +30,9 @@ public function actionError() { throw new \Exception('datadog'); } + + public function actionParameterized($value) + { + return 'Hello ' . $value; + } } diff --git a/tests/Integrations/Yii/V2_0/CommonScenariosTest.php b/tests/Integrations/Yii/V2_0/CommonScenariosTest.php index bc15432552..d9a3399364 100644 --- a/tests/Integrations/Yii/V2_0/CommonScenariosTest.php +++ b/tests/Integrations/Yii/V2_0/CommonScenariosTest.php @@ -53,6 +53,7 @@ public function provideSpecs() Tag::HTTP_STATUS_CODE => '200', 'app.endpoint' => 'app\controllers\SimpleController::actionIndex', 'app.route.path' => '/simple', + Tag::HTTP_ROUTE => '/simple', Tag::SPAN_KIND => "server", Tag::COMPONENT => "yii", ])->withChildren([ @@ -96,6 +97,7 @@ public function provideSpecs() Tag::HTTP_STATUS_CODE => '200', 'app.endpoint' => 'app\controllers\SimpleController::actionView', 'app.route.path' => '/simple_view', + Tag::HTTP_ROUTE => '/simple_view', Tag::SPAN_KIND => "server", Tag::COMPONENT => "yii", ])->withChildren([ @@ -142,6 +144,7 @@ public function provideSpecs() Tag::HTTP_STATUS_CODE => '500', 'app.endpoint' => 'app\controllers\SimpleController::actionError', 'app.route.path' => '/error', + Tag::HTTP_ROUTE => '/error', Tag::SPAN_KIND => "server", Tag::COMPONENT => "yii", ]) @@ -201,6 +204,50 @@ public function provideSpecs() ]), ]), ], + 'A GET request to a route with a parameter' => [ + SpanAssertion::build( + 'web.request', + 'yii2_test_app', + 'web', + 'GET /parameterized/?' + )->withExactTags([ + Tag::HTTP_METHOD => 'GET', + Tag::HTTP_URL => 'http://localhost:9999/parameterized/paramValue', + Tag::HTTP_STATUS_CODE => '200', + 'app.endpoint' => 'app\controllers\SimpleController::actionParameterized', + 'app.route.path' => '/parameterized/:value', + Tag::HTTP_ROUTE => '/parameterized/:value', + Tag::SPAN_KIND => "server", + Tag::COMPONENT => "yii", + ])->withChildren([ + SpanAssertion::build( + 'yii\web\Application.run', + 'yii2_test_app', + Type::WEB_SERVLET, + 'yii\web\Application.run' + )->withExactTags([ + Tag::COMPONENT => "yii", + ])->withChildren([ + SpanAssertion::build( + 'yii\web\Application.runAction', + 'yii2_test_app', + Type::WEB_SERVLET, + 'simple/parameterized' + )->withExactTags([ + Tag::COMPONENT => "yii", + ])->withChildren([ + SpanAssertion::build( + 'app\controllers\SimpleController.runAction', + 'yii2_test_app', + Type::WEB_SERVLET, + 'parameterized' + )->withExactTags([ + Tag::COMPONENT => "yii", + ]), + ]), + ]), + ]), + ], ] ); } diff --git a/tests/Integrations/Yii/V2_0/ModuleTest.php b/tests/Integrations/Yii/V2_0/ModuleTest.php index b16d4330a7..69fc8e42ce 100644 --- a/tests/Integrations/Yii/V2_0/ModuleTest.php +++ b/tests/Integrations/Yii/V2_0/ModuleTest.php @@ -42,6 +42,7 @@ public function testGet() Tag::HTTP_URL => 'http://localhost:9999/forum/new-york/new-york/manhattan?key=value&', Tag::HTTP_STATUS_CODE => '200', 'app.route.path' => '/forum/:state/:city/:neighborhood', + Tag::HTTP_ROUTE => '/forum/:state/:city/:neighborhood', 'app.endpoint' => 'app\modules\forum\controllers\ModuleController::actionView', Tag::SPAN_KIND => "server", Tag::COMPONENT => "yii", diff --git a/tests/Integrations/Yii/V2_0/ParameterizedRouteTest.php b/tests/Integrations/Yii/V2_0/ParameterizedRouteTest.php index 179c14d567..d91d67c221 100644 --- a/tests/Integrations/Yii/V2_0/ParameterizedRouteTest.php +++ b/tests/Integrations/Yii/V2_0/ParameterizedRouteTest.php @@ -42,6 +42,7 @@ public function testGet() Tag::HTTP_URL => 'http://localhost:9999/homes/new-york/new-york/manhattan?key=value&', Tag::HTTP_STATUS_CODE => '200', 'app.route.path' => '/homes/:state/:city/:neighborhood', + Tag::HTTP_ROUTE => '/homes/:state/:city/:neighborhood', 'app.endpoint' => 'app\controllers\HomesController::actionView', Tag::SPAN_KIND => "server", Tag::COMPONENT => "yii", diff --git a/tests/Integrations/Yii/V2_0/YiiDetailsTest.php b/tests/Integrations/Yii/V2_0/YiiDetailsTest.php index e296029d3d..84d737236a 100644 --- a/tests/Integrations/Yii/V2_0/YiiDetailsTest.php +++ b/tests/Integrations/Yii/V2_0/YiiDetailsTest.php @@ -43,6 +43,7 @@ public function testRootIndexRoute() Tag::HTTP_URL => 'http://localhost:9999/site/index', Tag::HTTP_STATUS_CODE => '200', 'app.route.path' => '/site/index', + Tag::HTTP_ROUTE => '/site/index', 'app.endpoint' => 'app\controllers\SiteController::actionIndex', Tag::SPAN_KIND => "server", Tag::COMPONENT => "yii",