@@ -388,23 +388,12 @@ function () use ($integration) {
388
388
}
389
389
);
390
390
391
- $ handle_route = function ($ request , $ rootSpan ) use ($ integration ) {
392
- $ route_name = $ request ->get ('_route ' );
393
- if ($ route_name === null ) {
394
- return ;
395
- }
396
- if (dd_trace_env_config ("DD_HTTP_SERVER_ROUTE_BASED_NAMING " )) {
397
- $ rootSpan ->resource = $ route_name ;
398
- }
399
- $ rootSpan ->meta ['symfony.route.name ' ] = $ route_name ;
400
-
401
- // the rest is for determining http.route
391
+ $ handle_http_route = function ($ route_name , $ request , $ rootSpan ) use ($ integration ) {
402
392
if ($ integration ->kernel === null ) {
403
393
return ;
404
394
}
405
395
/** @var ContainerInterface $container */
406
396
$ container = $ integration ->kernel ->getContainer ();
407
- $ cache = null ;
408
397
try {
409
398
$ cache = $ container ->get ('cache.app ' );
410
399
} catch (\Exception $ e ) {
@@ -437,13 +426,12 @@ function () use ($integration) {
437
426
if (isset ($ route )) {
438
427
$ rootSpan ->meta [Tag::HTTP_ROUTE ] = $ route ->getPath ();
439
428
}
440
-
441
429
};
442
430
443
431
\DDTrace \trace_method (
444
432
'Symfony\Component\HttpKernel\HttpKernel ' ,
445
433
'handle ' ,
446
- function (SpanData $ span , $ args , $ response ) use ($ integration , $ handle_route ) {
434
+ function (SpanData $ span , $ args , $ response ) use ($ integration , $ handle_http_route ) {
447
435
/** @var Request $request */
448
436
list ($ request ) = $ args ;
449
437
@@ -465,7 +453,14 @@ function (SpanData $span, $args, $response) use ($integration, $handle_route) {
465
453
$ rootSpan ->meta [Tag::HTTP_STATUS_CODE ] = $ response ->getStatusCode ();
466
454
}
467
455
468
- $ handle_route ($ request , $ rootSpan );
456
+ $ route_name = $ request ->get ('_route ' );
457
+ if ($ route_name !== null ) {
458
+ if (dd_trace_env_config ("DD_HTTP_SERVER_ROUTE_BASED_NAMING " )) {
459
+ $ rootSpan ->resource = $ route_name ;
460
+ }
461
+ $ rootSpan ->meta ['symfony.route.name ' ] = $ route_name ;
462
+ $ handle_http_route ($ route_name , $ request , $ rootSpan );
463
+ }
469
464
470
465
$ parameters = $ request ->get ('_route_params ' );
471
466
if (!empty ($ parameters ) &&
0 commit comments