Skip to content

Commit c39d385

Browse files
authored
Update span name if route is known (#205)
1 parent 37c6b0b commit c39d385

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/SymfonyInstrumentation.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ public static function register(): void
8383
$routeName = $request->attributes->get('_route', '');
8484

8585
if ('' !== $routeName) {
86-
$span->setAttribute(TraceAttributes::HTTP_ROUTE, $routeName);
86+
/** @psalm-suppress ArgumentTypeCoercion */
87+
$span
88+
->updateName(sprintf('%s %s', $request->getMethod(), $routeName))
89+
->setAttribute(TraceAttributes::HTTP_ROUTE, $routeName);
8790
}
8891
}
8992

tests/Integration/SymfonyInstrumentationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function test_http_kernel_handle_attributes(): void
4848

4949
$attributes = $this->storage[0]->getAttributes();
5050
$this->assertCount(1, $this->storage);
51-
$this->assertEquals('HTTP GET', $this->storage[0]->getName());
51+
$this->assertEquals('GET test_route', $this->storage[0]->getName());
5252
$this->assertEquals('http://:/', $attributes->get(TraceAttributes::URL_FULL));
5353
$this->assertEquals('GET', $attributes->get(TraceAttributes::HTTP_REQUEST_METHOD));
5454
$this->assertEquals('http', $attributes->get(TraceAttributes::URL_SCHEME));

0 commit comments

Comments
 (0)