Skip to content

Commit be97d9d

Browse files
authored
Add route name as HTTP_ROUTE attribute (#119)
1 parent 3564988 commit be97d9d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/SymfonyInstrumentation.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ public static function register(): void
6161
}
6262
$scope->detach();
6363
$span = Span::fromContext($scope->context());
64+
65+
$request = ($params[0] instanceof Request) ? $params[0] : null;
66+
if (null !== $request) {
67+
$routeName = $request->attributes->get('_route', '');
68+
69+
if ('' !== $routeName) {
70+
$span->setAttribute(TraceAttributes::HTTP_ROUTE, $routeName);
71+
}
72+
}
73+
6474
if ($exception) {
6575
$span->recordException($exception, [TraceAttributes::EXCEPTION_ESCAPED => true]);
6676
$span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage());

0 commit comments

Comments
 (0)