Skip to content

Commit 6f4230d

Browse files
committed
add test coverage
1 parent faca8d5 commit 6f4230d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Instrumentation/Laravel/tests/Integration/LaravelInstrumentationTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace OpenTelemetry\Tests\Contrib\Instrumentation\Laravel\Integration;
66

7+
use Exception;
78
use Illuminate\Routing\Router;
89
use Illuminate\Support\Facades\DB;
910
use Illuminate\Support\Facades\Http;
@@ -106,6 +107,16 @@ public function test_route_span_name_if_not_found(): void
106107
$this->assertSame('GET', $span->getName());
107108
}
108109

110+
public function test_records_exception_in_logs(): void
111+
{
112+
$this->router()->get('/exception', fn () => throw new Exception('Test exception'));
113+
$this->call('GET', '/exception');
114+
$logRecord = $this->storage[0];
115+
$this->assertEquals(Exception::class, $logRecord->getAttributes()->get(TraceAttributes::EXCEPTION_TYPE));
116+
$this->assertEquals('Test exception', $logRecord->getAttributes()->get(TraceAttributes::EXCEPTION_MESSAGE));
117+
$this->assertNotNull($logRecord->getAttributes()->get(TraceAttributes::EXCEPTION_STACKTRACE));
118+
}
119+
109120
private function router(): Router
110121
{
111122
/** @psalm-suppress PossiblyNullReference */

0 commit comments

Comments
 (0)